Generate Random Whole Numbers with JavaScript - What's wrong with my code?

Generate Random Whole Numbers with JavaScript - What's wrong with my code?
0

#1

My code gives me the correct answer but doesnt complete the challenge. The following criteria is incomplete;

You should have multiplied the result of Math.random by 10 to make it a number that is between zero and nine.

Can anyone figure out what’s wrong with solving the problem this way? Thanks in advance :slight_smile: x

Your code so far

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.
var a = Math.random(); 
  var b = a* 10; 
  var c = Math.floor(b); 
  return c;
}

Your browser information:

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

Link to the challenge:


#2
Math.floor(Math.random() * 10)

testing code is looking for this syntax.
you may report a bug, but whosoever wrote testing must validate your code, your code works just fine.

Also all the variables can be written as comma separated

  var a = Math.random(), 
      b = a * 10, 
      c = Math.floor(b); 
  return c;

There are already bugs reported for the same issue