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 trialTijl Declerck
1,211 PointsIt doesn't load the second prompt.
For some reason, my second prompt doesn't pop up/ Could you help me please?
var correctAnwers = 0;
var answer1 = prompt("Waar ben ik geboren?");
if (answer1.toUpperCase === UKKEL) {
correctAnswers += 1;
}
var answer2 = prompt("Hoe oud ben ik?");
if ( parseInt === 26) {
correctAnswers += 1;
}
var answer3 = prompt("Waar woon ik nu?");
if ( answer3.toUpperCase === MEDELLIN) {
correctAnswers += 1;
}
var answer4 = prompt("Hoe heet mijn vader?");
if ( answer4.toUpperCase === HUGO) {
correctAnswers += 1;
}
var answer5 = prompt("Wie mis ik het meest?");
if ( answer5.toUpperCase === KATE) {
correctAnswers += 1;
}
//This is the secion where the players get their results
if ( correctAnswers === 5 ){
document.write("Congratulations, you have answered every question correctly and you have earned the golden crown")
}else if (correctAnswers === 3 || correctAnswers === 4){
document.write("Congratulations, you have answered '+ correctAnswers + 'questions correctly and you have earned the silver crown")
}else if (correctAnswers === 1 || correctAnswers === 2){
document.write("Too bad, you only answered '+ correctAnswers + 'questions correctly and you have earned the bronse crown and you are no longer my friend")
}else {
document.write("Too bad, all your answers were awful please gtfo")
}
2 Answers
Steven Parker
231,269 PointsYou are attempting to use methods like attributes.
For example, toUpperCase is a method, and even though you don't pass it an argument you must put parentheses after it when you call it. Also, when you compare the result to a literal string, the string must be enclosed in quotes:
if (answer1.toUpperCase() === "UKKEL") { // NOTE: parentheses and quotes added
The prompts are all OK, but when the first error was encountered, the program ended and so no more prompts were seen.
H Yang
2,066 PointsI believe
if (parseInt(answer2) === 26) {
should work. You need to name which variable you're parsing. Please correct me if I'm mistaken.