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
charles bempah
1,295 PointsCan't get right output
I am unable to get the right output based on the score. It will give me one output regardless of the score. Please help
2 Answers
KRIS NIKOLAISEN
54,974 PointsI would have responded earlier but I thought someone else would have by now. Here is a snapshot where I provided updates and removed code I thought unnecessary. Rather than a detailed analysis I'll just say some things in general.
1) Statements like
parseInt(score)
or
else {
score
}
or
goldAward
on their own don't do anything
2) When comparing use a comparison operator instead of the assignment operator
if (question1 = answer1)
Use == or === instead. Same thing here:
if (score = 5)
3) Don't take shortcuts in your conditions
else if (score = 3 || 4)
should be
else if (score == 3 || score == 4)
4) Else statements don't need a condition
else (score = 0)
they execute when all previous conditions are false
charles bempah
1,295 PointsThank you very much