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 The Conditional Challenge Solution

John Rodrigo
PLUS
John Rodrigo
Courses Plus Student 2,172 Points

How 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.

John Rodrigo
John Rodrigo
Courses Plus Student 2,172 Points

code didn't come out the way I anticipated. Sorry

` is not a hyphen, it's a backtick. Blocks of code need to be surrounded by 3 backticks.

2 Answers

Hey 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
PLUS
John Rodrigo
Courses Plus Student 2,172 Points

Sorry, for the slow reply, holidays. Anyway, thanks for the update.