0

Math.random to guess a random number?

function guessMyNumber(number){ if (Math.floor(Math.random() * 6)) == (number){ return "yes"; }else{ return "no"; } } console.log(guessMyNumber(3));

1st Feb 2021, 10:23 PM
tristach605
tristach605 - avatar
2 Antworten
+ 1
Check if loop again, And correct it to following, if (Math.floor(Math.random() * 6) ==(number)){
1st Feb 2021, 10:32 PM
Abhay
Abhay - avatar
0
Thanks, Abhay:).
2nd Feb 2021, 1:49 AM
tristach605
tristach605 - avatar