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 trialJohn Rodrigo
Courses Plus Student 2,172 PointsHow do you make a prompt box work after you answer the first prompt box. Mine will not open for the second question?
// quiz begins, no answers correct
var correct = 0;
// questions
var answer1 = prompt("Name one of the original six hockey teams?");
if ( answer1.toUpperCase() === 'BOSTON BRUINS' ) {
correct += 1;
}
var answer2 = prompt("Name one of the original six hockey teams?");
if ( answer2.toUpperCase() === 'CHICAGO BLACKHAWKS' ) {
correct += 1;
Fixed that for you. - Dane E. Parchment Jr. (Moderator)
P.S. - Remember that to show code you must first place them between a pair of three hyphens: `
Check the markdown cheatsheet for information.
ursaminor
11,271 Points` is not a hyphen, it's a backtick. Blocks of code need to be surrounded by 3 backticks.
2 Answers
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 PointsHey John, your second if-conditional reads like this:
if ( answer2.toUpperCase() === 'CHICAGO BLACKHAWKS' ) {
correct += 1;
You left out the second curly brace. It should look like this:
if ( answer2.toUpperCase() === 'CHICAGO BLACKHAWKS' ) {
correct += 1;
}
When you finish the conditional with the second curly brace, it works. The first line of defense against bugs in your code is finding and fixing simple typos, which are very easy to make and also easy to over-look. After fixing the typo, try running the entire thing again.
John Rodrigo
Courses Plus Student 2,172 PointsSorry, for the slow reply, holidays. Anyway, thanks for the update.
John Rodrigo
Courses Plus Student 2,172 PointsJohn Rodrigo
Courses Plus Student 2,172 Pointscode didn't come out the way I anticipated. Sorry