Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <button id="btn"> Cliccami e diventero' rosso </button>
- <script>
- const bottone = document.getElementById("btn");
- bottone.addEventListener("click", function ()
- {
- this.style.color = "white";
- this.style.backgroundColor = "red";
- });
- function genera_casuale(lim_inferiore, lim_superiore)
- {
- const estratto = lim_inferiore + Math.floor(Math.random() *
- (lim_superiore - lim_inferiore + 1));
- return estratto; //valore restituito al chiamante
- }
- function sommaArray(a)
- {
- let somma = 0;
- for (let i=0; i<a.length; i++) somma += a[i];
- return somma;
- }
- const somma = function (a)
- {
- let somma = 0;
- for (let i=0; i<a.length; i++) somma += a[i];
- return somma;
- }
- //let scelta = Math.floor(Math.random()*5); //intero random da 0 a 4
- for (let i=0; i<200; i++)
- console.log ( genera_casuale(12, 18) );
- console.log(somma([1,1,1,1,1]));
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement