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 Boolean Values

Christian Solorzano
Christian Solorzano
6,606 Points

Browser not showing my code.

I followed step by step and somehow, I can't get my code to run in Chrome.

Here's what I've typed

var correctGuess = false; var randomNumber = Math.floor(Math.random() * 6 ) + 1; var guess = prompt('I am thinking of a number between 1 and 6. What is it?'); if (parseInt(guess) === randomNumber ) { correctGuess = true; } if (correctGuess===true) { document.write('<p>You guessed the number!</p>'); } else { document.write(' <p> Sorry. The number was ' + randomNumber + ' . </p>); }

Console is saying: Uncaught SyntaxError: Unexpected token ILLEGAL

2 Answers

Julian Aramburu
Julian Aramburu
11,368 Points

Hi Christian! I don't know if that's the problem but in your else statement you missed a quote after the p closing tag so I guess it muts be taking the . as a illegal or unexpected token!

Hope it solves the problem!

Cheers and Keep Coding!

Christian Solorzano
Christian Solorzano
6,606 Points

Yep! That was it. That last quote.

Thanks so much. I was starting to get angry. Lol

Julian Aramburu
Julian Aramburu
11,368 Points

Great! Happy Coding! Quick tip: When the console gives you that kind of message , on the right of the error , it points out in what line of your code the error is taking place, and if you click it you are taken directly to that piece of the code! So debugging is easier!