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

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!