Tell us what’s happening:
Hello, I am having trouble with understanding that why is FCC not accepting when I put console.log around Math.random, but it accepts the other two ways, can someone explain?
Your code so far
function randomFraction() {
// Only change code below this line
return console.log(Math.random());
// Only change code above this line
}
However below two methods work : 1.
function randomFraction() {
// Only change code below this line
return Math.random();
// Only change code above this line
}
2.
function randomFraction() {
// Only change code below this line
var aa = Math.random();
return console.log(aa);
// 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/86.0.4240.111 Safari/537.36.
Challenge: Generate Random Fractions with JavaScript
Using console.log only prints your answer to the screen. It does not actually return your value out of your function for another piece of code to use.
You need to return values when the challenge asks you to return something. If you want to view the output, you should wrap the output of your function in a console log.