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 trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

.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.

Cheo R
Cheo R
37,150 Points
if (answer_1.toUpperCase === "STEVE JOBS") {

Looks like you forgot to call the .toUpperCase function with parenthesis, ().

2 Answers

Steven Parker
Steven Parker
231,269 Points

When 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
Hanan Fadah
1,131 Points

You Forgot the parentheses () right after .toUpperCase.