mardi 29 décembre 2020

Random Numbers without repeat. Beginner Lvl

I've learning JS for a week so I know, it's terrible code. However I have a question. How can I randomly generate numbers without repetition in this case? Btw. sorry for my english XD

let lottoArray = [];

lottoGame()

function lottoGame () {
    do {
        let addNumber = Math.floor(Math.random()* 30);
        lottoArray.push(addNumber)
        console.log(addNumber)
    }  while(lottoArray.length <= 5 ) {
          
       }
       document.querySelector('.loti').innerHTML = lottoArray 
}



Aucun commentaire:

Enregistrer un commentaire