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
Jason Frye
8,235 PointsProgram Code Order
In one of the beginning JavaScript videos, I thought I heard the program would execute the lines of code from top to bottom. In this code, I had a small error in the third line that kept even the first prompt from showing.
var HTMLBadges = prompt("How many HTML badges do you have?"); var CSSBadges = prompt("How many CSS badges do you have?"); var totalBadges = HTMLBadges + CSSBadges; alert("Wow! You have " + totalBadges + " badges!");
If the error was in the third line and the program runs the code from top to bottom, why wouldn't the first two prompts show but not complete or error out anything on the third line and after?
Thanks for helping me to better understand JavaScript!
1 Answer
Clayton Perszyk
Treehouse Moderator 49,047 PointsThe code is compiled before it is run; if there is an error anywhere in the code, it will cause the program to fail.