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

Dylan Davenport
Dylan Davenport
Courses Plus Student 2,645 Points

Missing ) after statement??

I wrote some code for the quiz project and went to test it. It says that i am missing a parenthesis somewhere after the first if statement but I can't seem to find where. Any thoughts? Below is the code thus far:

var questions = 5;

alert('Welcome to the JS quiz! You will be asked 5 questions, at the end depending on your success you will be awarded a crown. Good Luck!');

var question1 = prompt('What is the capital of the United States?');
if ( question1 === 'Washington DC' ) {
  document.write('CORRECT! you have ' + (questions - 1) ' left, keep going.');

} else {
  document.write('WRONG! Sorry. Maybe the next question will be easier. ' + 'You have ' + (questions - 1) ' left.');

Moderator edited: Markdown added so code will display properly in the forums.

2 Answers

You are missing the '+' symbol to concate (questions-1) to the string 'left, keep going. It need to be on both sides of the operation: + (questions-1) +.

You have the same issue in the else document write statement. It is easy to forget the second plus sign. I mistake I make about 50 times before it became habit.

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there, Dylan! From what I can see, it looks like you have a problem in your first document.write. You've written:

document.write('CORRECT! you have ' + (questions - 1) ' left, keep going.');

Try changing it to:

document.write('CORRECT! you have ' + (questions - 1)  + ' left, keep going.');

It looks like you simply omitted a concatenation operator on accident. Note the extra + sign in the second version between the variable and the ending string.

Hope this helps! :sparkles:

edited for additional information

And Larry is correct, it's also missing from the second document.write statement.