Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="it-IT">
- <head>
- <meta charset="UTF-8">
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css"
- rel="stylesheet"
- >
- <style>
- </style>
- <title>CICLI</title>
- </head>
- <body>
- <script>
- function test()
- {
- //un numero casuale con la virgola tra 0 compreso e 1 escluso
- let estratto = Math.random();
- estratto *= 5; //un numero casuale tra 0 e 4,99999...
- estratto = Math.floor(estratto); //un numero INTERO casuale: 0, 1, 2, 3 o 4
- return estratto;
- //variante con UNA sola riga al posto di tutte le precedenti
- //return Math.floor(Math.random()*5);
- }
- </script>
- <script>
- let numero_positivo=0;
- //for (;numero_positivo<=0;) numero_positivo = parseInt(prompt("inserire un numero maggiore di 0"));
- // do
- // {
- // numero_positivo = parseInt(prompt("inserire un numero maggiore di 0"));
- // if (numero_positivo<=0) alert("Solo numeri maggiori di zero");
- // }
- // while (numero_positivo<=0);
- let risultato=0;
- // while( (risultato = test() )>0 )
- // console.log(risultato);
- do
- {
- console.log(risultato=test());
- }
- while (risultato>0);
- </script>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement