Javascript Random. Bug?


#1

Hello im just re doing the Javascript lessons, im at the lesson called “Random”

The step number 1 is: Inside of a console.log, create a random number with Math.random, then multiply it by 100.

If you run the program few times, you’ll see random numbers in the console.

I type the code “console.log(Math.random()*100);” without the quotes.
It does give me several random numbers between 0 and 100, so it seems like everything is okay
however the tick is marked as if it is wrong, is there anything wrong? it feels like it is a bug

i dont want to “get the code” because that gives me the whole code for the whole lesson and that means i wont learn anything basicly, thanks.


#2

Try with a little bit of white space…

console.log(Math.random() * 100);

#3

The code didnt work anyway, then when i did ctrl + f5 and tried your code again, it worked, was it my error? like if i ever get to more advanced programming, the lack of those spaces is going to give errors? because the code worked, it did give me random numbers.
or was it just codecademys error?


#4

The spaces was just a suggestion. The code works fine either way. I like to make a habit of always wrapping operators with white space so they stand out. White space is free and helps a tonne during debugging or analysis.


#5

Perfect thanks! :smiley: