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

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,824 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


//Put 3 more backticks at the bottom.