<html>
  <head>
  <script language="javascript">
  function indov() {
  num = Math.floor(Math.random() * 101);
  tent = prompt("quanti tentativi vuoi?");
  do {
  n = prompt("dammi numero da 0 a 100");
  if (n==num) {
  tent = 0;
  document.write("hai indovinato il numero " + n);
  } else {
  tent--;
  if (n<num) {
  window.alert("il numero è troppo piccolo");
  } else {
  window.alert("il numero è troppo grande");
  }
  if (tent==0) {
  document.write("non hai indovinato il numero " + num);
  }
  }
  } while (tent>0);
  return ""
  }
  </script>
  </head>
  <body>
  <script language="javascript">
  document.write(indov())
  </script>
  </body>
  </html>