+ 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
10 odpowiedzi
+ 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);
+ 9
Happens to best of us 😉
Good luck
+ 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
+ 4
Frost lol wow such a small mistake was giving me headache thank you I really appreciate
+ 4
Also why isnt it giving me multiple random numbers it's just giving me the same multiple timrs
+ 4
Yes I got it now thank you
+ 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
+ 1
try alerting the message instead.