Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

Gaura Allen
Gaura Allen
2,407 Points

Browser is not executing if loop? My syntax must be wrong but I cant find where.

For some reason the contents of my if loops are not running. Am I just having a blonde moment in regards to my syntax?

//quiz result counter. Should start at zero and incramentaly increase in value var counter = 0;

alert("Welcome to Gaura's Game of Thrones Quiz!"); var q1 = prompt("Who is Eddard Stark's bastard son?"); //Question one. if (q1.toUpperCase() === "Jon Snow" || q1.toUpperCase() === "John Snow") { //counter increases by one point and an alert lets the user know they were correct. counter += 1; alert("Good Job!"); } else { alert("Sorry, wrong answer!"); } console.log(counter)

1 Answer

Michael Gardiner
Michael Gardiner
4,282 Points

Hi Guara! You must change your syntax to read: if (q1.toUpperCase() === "JON SNOW" || q1.toUpperCase() === "JOHN SNOW") because you are putting the answer into all caps, so the correct answer must also be in all caps! If this answer helped you please hit Best Answer!

Gaura Allen
Gaura Allen
2,407 Points

If you could see the look on my face right now. I don't know how I missed that so many times! Thanks so much!