+ 9

Why is this not working

Am trying to push the random numbers into the array but it's not working https://code.sololearn.com/WmybLMFtD3QR/?ref=app

15th Dec 2018, 4:54 AM
idris
idris - avatar
10 Respostas
+ 14
you didn't define the array correctly, use square brackets instead of curly ones var dice=[]; //square brackets var rand=(Math.random() *6 ) + 1; var wholeNum=Math.floor(rand); for(var i =0; i<5; i++){ dice.push(wholeNum); } console.log(dice);
15th Dec 2018, 4:57 AM
Frost
Frost - avatar
+ 9
Happens to best of us 😉 Good luck
15th Dec 2018, 5:00 AM
Frost
Frost - avatar
+ 7
Because you are generating random number outside of the loop which results only generation of one random no which will get pushed into array... I guess you got it
15th Dec 2018, 5:07 AM
Frost
Frost - avatar
+ 4
Frost lol wow such a small mistake was giving me headache thank you I really appreciate
15th Dec 2018, 5:00 AM
idris
idris - avatar
+ 4
Also why isnt it giving me multiple random numbers it's just giving me the same multiple timrs
15th Dec 2018, 5:01 AM
idris
idris - avatar
+ 4
Yes I got it now thank you
15th Dec 2018, 5:08 AM
idris
idris - avatar
+ 1
I had make video of solo learn plz watch this. And subscribe my YouTube channel ->Clank Tech Ankit Parajuli Don't post unrelated things on threads. If you're going to advertise, keep it to just your feed
15th Dec 2018, 3:07 PM
Ankit Parajuli
Ankit Parajuli - avatar
+ 1
try alerting the message instead.
15th Dec 2018, 11:36 PM
chz3369
chz3369 - avatar