Basic JavaScript - Generate Random Whole Numbers within a Range

I know the formula is correct and I’ve even tried console.log the function to verify that it passes all the test but the actual test won’t pass my solution. Is this bug in editor?

its showing error only for the 2nd test which is highest random number generated should ne equal to myMax.

Your code so far

function randomRange(myMin, myMax) {
  // Only change code below this line
myMin =5;
myMax = 10;
  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/106.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Generate Random Whole Numbers within a Range

Link to the challenge:

why do you need these?

I added them because I thought I had to specify my own range . I tried removing those earlier but the test still failed. it worked this time somehow haha. Thank you

these values should come from the parameters of the function.
(when you wrote these two lines you were effectively over-writing the inputted values so the test was failing because of that)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.