Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.