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 trialWilfredo Casas
6,174 PointsAll works well except the conditionals, why?
quesnum = 3
punt = 0
question1 = prompt('what the capital of Kazajistan?' + " " + quesnum);
quesnum -= 1;
if (question1.toUpperCase === "KAZA") {
punt += 1 ;
};
question2 = prompt('who was the the 24th president of the usa' + " " + quesnum);
quesnum -= 1;
if (question2.toUpperCase === "LINCOLN") {
punt += 1 ;
};
question3 = prompt('how long in meters is the eiffel tower?'+ " " + quesnum);
quesnum -= 1;
if (question3.toUpperCase === "14") {
punt += 1;
};
if (punt === 3) {
alert ('you are badass')
}
else if (punt === 2) {
alert ('you are kick ass')
}
else if (punt === 1) {
alert ('you are all right')
}
else {
alert ('you lost')
}
2 Answers
Ted Dunn
43,783 PointsYou do not have semicolons (;) after the statements in the blocks for your conditionals.
Jason Anello
Courses Plus Student 94,610 PointsHi Wilfredo,
In your calls to the .toUpperCase()
method you forgot to put parentheses at the end. Example: question1.toUpperCase
Without the parentheses it won't call the method. Instead it's a reference to the method. So you're always comparing if a function reference is equal to some string.
Joey Frazer
Courses Plus Student 129 PointsJoey Frazer
Courses Plus Student 129 PointsIn JavaScript I don't believe you need semicolons.