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 trialAidan Palmer
5,844 Points.toUpperCase messing up my program?
//start the user off with NO correct answers
var correctAnswers = 0
//question 1
var question_1 = prompt("Who founded apple?")
var answer_1 = question_1
if (answer_1.toUpperCase === "STEVE JOBS") {
alert("Correct!");
correctAnswers += 1;
} else {
alert("Sorry that's wrong. The correct answer is Steve Jobs");
}
there is my code, it works without the ".toUpperCase" method. Now, whenever I input "Steve Jobs" It gives me the else statement.
2 Answers
Steven Parker
231,275 PointsWhen calling a function, you must always have parentheses after the function name, even if it takes no arguments (as in this case):
if (answer_1.toUpperCase() === "STEVE JOBS") {
Hanan Fadah
1,131 PointsYou Forgot the parentheses () right after .toUpperCase.
Cheo R
37,150 PointsCheo R
37,150 Pointsif (answer_1.toUpperCase === "STEVE JOBS") {
Looks like you forgot to call the .toUpperCase function with parenthesis, ().