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 trialBrian Njenga
3,973 Pointsbesides 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"); }
1 Answer
Steven Parker
231,269 PointsYou 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.
Brian Njenga
3,973 PointsThanks
Aryaman Dhingra
3,536 PointsAryaman Dhingra
3,536 PointsIt would be helpful to provide some code so we can know exactly what you're talking about.