Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Build a Random Number Guessing Game

Why didn't we type var RandomNumber = Math.floor(Math.random() *6 )+1 in the 2nd line instead of 1st ?

When I wrote this code in the 2nd line, and the prompt command in 2nd line my code didn't work.

Ivan Saveliev
Ivan Saveliev
9,153 Points

Hi Friend, if you still need assistance please add your code, because it's hard to understand what's the problem.

4 Answers

Hi Bhavya, Did you remember to save your script.js file?

Hi Bhavya, Did you remember to save your script.js file?

Erik Veerman
Erik Veerman
3,988 Points

If you want to test the program for a right answer, it can take a lot of tries before you guessed right.

You can put a console.log(randomNumber) on line 2 and cheat the program for testing purposes. If you put the prompt first you cannot do this.