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 trialJake Guss
Front End Web Development Techdegree Student 5,855 PointsAll 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
7,551 PointsYeah i just noticed the parseInt part. Try this one. (firstAnswer === 'fifty' || parseInt(firstAnswer) === 50)
Robert Lyon
7,551 PointsWithin the if statement try changing the condition to, (firstAnswer === 'fifty' || firstAnswer === parseInt('50'))
Jake Guss
Front End Web Development Techdegree Student 5,855 PointsI am now listed as being wrong when inputting the integer 50, , whether I put string quotes around parseInt('50') or not.
Irfan Hussain
Courses Plus Student 6,593 PointsYes 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.