Random Integer in Range Solution is not correct

Random Integer in Range Solution is not correct

Tell us what’s happening:

Hello. The provided solution is not correct based on the description of the problem.

It says it must return a random Integer between the two input values. But then we must use ceiling of myMin because if a non-integer is fed to the function it will return a non-integer in violation of the problem.

And we also must use floor of myMax

Otherwise input parameters like myMin=0.1,myMax=1.9 which should Only return 1, will return 1-2

I suggest fixing the solution to be true for non-Integer inputs and adding them to the test conditions or specifying in problem it will give random Integer values inclusive between two integers only.

Ben Westgate

Your code so far

// Example
function ourRandomRange(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

return Math.floor(Math.random()*(myMax-myMin+1))+Math.ceil(myMin); // Change this line


// Change these values to test your function
var myRandom = randomRange(5, 15);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0.

Challenge: Generate Random Whole Numbers within a Range

Link to the challenge: