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 Improving the Random Number Guessing Game

Why are the extra "}" needed to run the program??

I was in AGONY for 30 minutes ripping my hair out trying to figure out why my prompt box wouldn't pop up.

I checked the spellings and the syntax over and over again....UNTIL I FOUND THE PROBLEM!

In the video demonstration, on line 10 and line 15 are the extra "}" before the next "}" right in front of the "else if".

I input them in and voila, it worked.

But why do I need to put an extra "}" in for it to work? The teacher didn't need to add an extra "}" at the end of line 5 in order for it to work.
Why are line 10 and line 15 special?

2 Answers

Hugo Paigneau
Hugo Paigneau
4,253 Points

once you openned a "{", you need to close it with } In line 5 there was a simple if statement so : if{ }

But line 10 and 15, there are another if inside the if statement so :

if{ if{ } }

ah! THANK YOU HUGO!