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

Not adding up

Here it is my code but it is not responding...

// quiz begins, no answer correct var correct = 0;

// ask questions var answer1 = prompt('Name the best team in the NBA'); if (answer1.toUpperCase() === 'HAWKS'); { correct += 1; } var answer2 = prompt('Name the best MLB team'); if (answer2.toUpperCase() === 'DODGERS' || answer2.toUpperCase() === 'LA'); { correct += 1; }

if (correct === 2){ document.write('you are great'); } else if (correct === 1){ document.write('you are good') } else { document.write('watch espn'); }

Ryan Zimmerman
Ryan Zimmerman
3,854 Points

Rick,

Best way to tackle this problem is to use console.log to see which variables are returning what.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Well, you've got the logic! So kudos. It's the syntax that's tripping you up. You have some stray semicolons all over the place (mainly after your conditional statements). Remember a semicolon is used to end a statement. So if we want to ask if something is less than 5 we do it like this:

if(myNum < 5) {
  doSomeCodeHere();
}

Notice how the semicolon comes after each statement inside the block. Not after the parentheses in the conditional. I reworked your code so that it functions now. Take a look:

var correct = 0;

var answer1 = prompt('Name the best team in the NBA'); 
if (answer1.toUpperCase() === 'HAWKS')
 { 
    correct += 1; 
 } 
var answer2 = prompt('Name the best MLB team');
 if (answer2.toUpperCase() === 'DODGERS' || answer2.toUpperCase() === 'LA') {
    correct += 1; 
 }

if (correct === 2){ 
    document.write('you are great');
} else if (correct === 1) { 
document.write('you are good');
 } else {
 document.write('watch espn'); 
}

Hope this helps! :smiley:

great...thanks..."semicolon" sold me out....