How to format code?


How to format code?

I am a newbie at JavaScript, (at least “real” Javascript. I took Khan academy’s course a while ago.) and I don’t know how to format this piece of code.

Math.floor(Math.random() * 50); I don’t know where to put the semi-colons and parenthesis that this line calls for and I can’t seem to get it right. Please help!


That is all correct, but for the 50 which should be 100.

Math.random() is written like that, with nothing in the argument.

Math.floor(argument) is written like that, and it takes an argument.

In the case above, the argument is Math.random() * 100.

Are these two functions new to you?


I’m sorry, I worded that wrong. I meant to say how do I put the code into a console.log so that it shows up on the screen? I tried every way I could think of and it still wouldn’t work.



where expression is the code above (without the semi-colon)


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