0
How can i generate 5 random numbers between 1 and 6 in JavaScript. Math.Random only generates 1 number per time.
12 Answers
+ 7
function display() {
let min = 1 , max = 6
document.write(Math.floor(Math.random() * 10 % ((max - min) + min)) + 1)
document.write("<br>")
}
for(let i = 0; i < 5; i++) {
display()
}
Displays from 1 to 6
+ 11
Bolaji Olayinka Hi, dont be so mad. ~ swim ~ gave you more than a plain answer. He told you the way of doing this ;>
Also bear in mind he's not the one who wants to show off :)
+ 1
I would use a loop to generate 5 different random numbers. It's the simplest way, even though there's likely more streamlined and complex ways
+ 1
here you did not ask me, and I will answer you
https://code.sololearn.com/Wr3ZSJjKMZHP/?ref=app
0
Thanks, but i dont know how to
0
~ swim ~
var intelligence ="stupid";
for (var i=0; i<=3; i++){
console.log("not" + "" + "intelligence")
}
- 1
Thanks for your time, the fact that u know something doesnt give u a privilege of talking down on newbies. pls give room for people to answer my question
- 2
I dont think u need to comment, what u gave isnt an answer, it is not needed. I know how to loop, but i havent looped through random nums before