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 trialJonathan Ramirez
6,284 PointsScript not running
Hi guys,
I need help debugging this. I just need an extra pair of eyes to spot where my code went wrong. I'm not even getting the first dialogue box. (Oddly, when I delete everything including the first "else if" and after, then the first dialogue box runs just fine.)
Is it possibly because I have indentation wrong?
3 Answers
Devron Baldwin
3,508 PointsGenerally using a decent IDE will help with this sort of thing. The markup syntax highlighting tends to show you where the code has gone a bit sideways.
I use Netbeans (http://www.netbeans.org) but you can use more lightweight IDEs like Sublime Text (http://www.sublimetext.com).
Also it's worth checking out the console logs on your web browser. They will generally tell you what the issue is or at least point you in the general direction.
Devron Baldwin
3,508 PointsHi Jonathan,
You are missing an opening bracket on this line
if parseInt(guessLess) === randomNumber) {
It should be
if(parseInt(guessLess) === randomNumber) {
Also the final line has an error.
document.write("<p>Sorry. The number was ' + randomNumber + '.</p>");
You need to close a string with the same kind of quotes as you opened it. In this case you opened with a " and so you must close the string with a ". As below:
document.write("<p>Sorry. The number was " + randomNumber + ".</p>");
I hope that helps!
Jonathan Ramirez
6,284 Pointsah that's embarrassing! Thanks so much! I was going crazy trying to find the error. Lesson learned!
Jonathan Ramirez
6,284 PointsJonathan Ramirez
6,284 Points