Tell us what’s happening:
Describe your issue in detail here.
Hello freeCodeCampers!
I’m having a hard time understanding this formula and how it works, particularly the +1
. Any small hint will be greatly appreciated.
**Your code so far**
function randomRange(myMin, myMax) {
// Only change code below this line
return Math.floor(Math.random() * (myMax - myMin +1)) + myMin;
// Only change code above this line
}
console.log(randomRange(10,5));
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36
Challenge: Generate Random Whole Numbers within a Range
Link to the challenge: