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

Ivan Kozhunkov
PLUS
Ivan Kozhunkov
Courses Plus Student 8,480 Points

S.O.S.! Problems with if/else conditions!

My code:

var counter = 0;

var firstQuestion = prompt ('Which is a currency unit in Germany?');

if (firstQuestion.toUpperCase === 'EURO')

{ counter += 1; }

else {

alert ('Answer is not correct');

counter = 0; }

var secondQuestion = prompt ('In which year first 13 colonies was signatured The Independence Declaration');

if (secondQuestion.parseInt === 1776)

{ counter += 1; }

else {

counter;

alert ('Answer is not correct'); }

Have 2 variables - firstQuestion and secondQuestions. No matter what I enter in my prompt window, always opens alert message, talking that "Answer is not correct", even if an answer is correct.

1 Answer

Steven Parker
Steven Parker
231,236 Points

You must include parentheses when calling a method.

When you call a method like toUpperCase() or parseInt(), you must use parentheses after the name even if no argument is being passed. The name alone represents the method itself, but does not invoke it.