Challenge [Generate Random Whole Numbers with JavaScript](https://www.freecodecamp.com/challenges/generate-random-whole-numbers-with-javascript
User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
var randomNumberBetween0and19 = Math.floor(Math.rando
m() * 20);
function randomWholeNum() {
// Only change code below this line.
var rand = Math.random() * 10;
return Math.floor(rand);
// return Math.floor(Math.random() * 10); //works fine
//but above doesn't work
}

Sorry, about that
Following code works fine for me-
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
function randomWholeNum() {
// Only change code below this line.
var rand = Math.floor(Math.random() * 10);
return rand;
}
Code you posted also worked fine in my browser.
I did checked both in Morzilla Firefox and Microsoft Edge.
User Agent for Morzilla Firefox- Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
User Agent for Microsoft Edge- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
@ranaamritparth Just to confirm you have tested this :
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
function randomWholeNum() {
// Only change code below this line.
var rand = Math.random() * 10;
return Math.floor(rand);
}
The original description has some code that can give a false positive.
I am going to test it in google chrome. @raisedadead did you tested it on chrome?
I added the confirmed tag after that actually. :confused:
@raisedadead I was reading source code, maybee it has to take something with regex. Blow is code-
common.tests = ["assert(typeof randomWholeNum() === \"number\" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), 'message: The result of <code>randomWholeNum</code> should be a whole number.');","assert(code.match(/Math.random/g).length > 1, 'message: You should be using <code>Math.random</code> to generate a random number.');","assert(code.match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || code.match(/c/g), 'message: You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.');","assert(code.match(/Math.floor/g).length > 1, 'message: You should use <code>Math.floor</code> to remove the decimal part of the number.');"];
Such kind of error also happens when you copy-paste code. This happened once with me.
@avirajkhare00 I am sorry, I am a bit swamped at the moment on some stuff. But please feel free to leave your analysis here an someone will get back. Also It would be awesome if you can come up with a fix or a PR!
Thanks for looking into this.
@raisedadead Yes, I have tested the code many times.
Content Hidden - by mod [raisedadead]
whats your opinion bout my code