Need explanation for a JavaScript challenge

I was able to complete it. But I didn’t understand anything
Could someone tell me how it works
“Take a moment to read it and try to understand what this code is doing”
I tried.

The part I am not understanding :-

return Math.floor(Math.random()*(myMax-myMin + 1)) + myMin;

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
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Generate Random Whole Numbers within a Range

Link to the challenge:

something specific here you do not understand?

try to sub in two possible values for myMax and myMin and resolve the values

I want to understand the way it works.

Not what is happening behind the scenes. I want to understand the code

you can do it! take pen and paper and try to see what’s going inside the parenthesis
for example, if myMin is 4 and myMax is 7…

Math.floor(Math.random()*(7- 4 + 1)) + 4;

what happens next?

2 Likes