Please explain in detail so that I can understand the behind the scene of this kinda task. Thanks in advance
Hi! I’m not going to explain it in detail, because that’s the fun but you’ll want to start with the Math.random()
function, which returns a number between 0 and <1. To make that number into an integer there’s another Math function, Math.floor()
, and to get it between a certain range you’ll have to do some multiplication. That should get you reasonably well-started!
I always recommend checking out the MDN docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
2 Likes