My task is to print out random numbers until I get 5 and then stop the loop. I tried searching around the net but couldn't really find a solution. I'm still learning the basics so sorry if this was answered, can't seem to find an answer. Here's what I tried:
function myFunction(){
let x=Math.floor(Math.random()*6)+1;
if(x!==5){
document.getElementById('output').innerHTML=x;
}
else{
document.getElementById('output').innerHTML="5";
}
}
Aucun commentaire:
Enregistrer un commentaire