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

Jake Guss
seal-mask
.a{fill-rule:evenodd;}techdegree
Jake Guss
Front End Web Development Techdegree Student 5,855 Points

All my quiz responses come back as correct answers.

//All answers to firstAnswer are considered correct. What's am I doing wrong?

var rightAnswers = 0;
var correct = "You're correct!";
var wrong = "You're wrong.";

alert('Welcome to the quiz. This quiz consists of 5 questions. good luck!');
var firstAnswer = prompt('How many states are there in the U.S.A.?');
if (firstAnswer === 'fifty' || parseInt('50')) { alert(correct);
rightAnswers +=1;
    }
else {alert(wrong);
     }

3 Answers

Robert Lyon
Robert Lyon
7,551 Points

Yeah i just noticed the parseInt part. Try this one. (firstAnswer === 'fifty' || parseInt(firstAnswer) === 50)

Robert Lyon
Robert Lyon
7,551 Points

Within the if statement try changing the condition to, (firstAnswer === 'fifty' || firstAnswer === parseInt('50'))

Irfan Hussain
Irfan Hussain
Courses Plus Student 6,593 Points

Yes its wrong if you add string sing with numeric value. I will explain: You are trying to convert user input to integer value then try to pass it with string value. How its possible. More detail: 1) You enter 50 on prompt. 2) Value was string your convert to integer. 3) Then you try to pass with string again.

I hope this will help you.