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 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
216,148 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