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

besides keeping track of the number of correct answers, how can i keep track of the ones that the player missed

besides keeping track of the number of correct answers, how can i keep track of the ones the player missed and get to notify them other than just simply letting them know of the crown they earned in the game? Here's a snippet of the code Dave provided for the challenge solution: it basically rewarded players with a crown for correct answers, but didn't alert them on the questions they missed. The questions were 5. var correctAnswer = 0; var firstAnswer;

firstQuery = prompt("What's the best programming language?"); firstAnswer. toUpperCase("Javascript"); if(firstAnswer === firstQuery) { correctAnswer +=1;

} var secondQuery; var secondAnswer; secondQuery = prompt("what is the programming language that is named after a snake?"); secondAnswer.toUpperCase("Python") if(secondAnswer === secondQuery) { correctAnswer +=1;

} if(correctAnswer >= 2) { document.write("Congratulations! You've won the gold crown by getting" + correctAnswer); } else if (correctAnswer < 1) { document.write("Sorry you haven't won any crown"); }

Aryaman Dhingra
Aryaman Dhingra
3,536 Points

It would be helpful to provide some code so we can know exactly what you're talking about.

1 Answer

Steven Parker
Steven Parker
229,744 Points

You could keep a count of missed answers similarly to how the correct answer count is currently maintained. Simply create another variable (perhaps named "missedAnswer"), and after every "if" that tests for a correct answer and increments the original value, add an "else" that increments the new one.

If you were thinking about keep track of specific missed questions, you might want to hold that thought until you get through the courses covering array manipulation.

Thanks