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

Rui Neves
Rui Neves
3,393 Points

My code and how do I organize it.

var myNum = Math.floor(Math.random() * 5) + 1; //Generates a random number. console.log(myNum); //Log it to the console to make sure is not the same as the user wrote.

var guessNum = prompt('Try to guess the number I am thinkin of, between 1 and 5!'); // Question the user for a number.

if(parseInt(guessNum) === myNum){ //Checks if the number from th user is the same as the on generated. document.write('Congrats! You Guess it!'); //Give the answer. } else { document.write('Sorry, not this time! The number was ' + myNum + ".")//Give the answer with the rigth number.

1 Answer

Antony .
Antony .
2,812 Points

First type 3 back ticks on top of your code followed by the programming language you are using, then put 3 more backticks at the bottom of your code. So like this

```javascript

//Put 3 more backticks at the bottom.