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 trialGena Israel
2,047 Pointsi wrote it like the solution and it still won't prompt
//quiz begins, no answers correct var correct= 0;
//Ask 5 questions var Question1= prompt('What language do they speak in Brazil?');
var Question2= prompt('What language do they speak in Spain besides Spanish?');
var Question3= prompt('What language do they speak in Portugal?');
var Question4= prompt('What language do they speak in Canada besides English?');
var Question5= prompt('What language do they speak in some parts of Haiti?');
//Correct corresponding answers
if ( Question1.toUpperCase() === 'PORTUGUESE'){
correct+=1;
}
if (Question2.toUpperCase() === 'CATALAN'){
correct+=1;
}
if (Question3.toUpperCase() === 'PORTUGUESE'){
correct+=1;
}
if (Question4.toUpperCase() === 'FRENCH'){
correct+=1;
}
if (Question5.toUpperCase() === 'CREOLE'){
correct+=1;
}
//Badges if (correct=+=5 { document.write('Congrats, you have earned the Gold Medal!'); } else if (correct>=3){ document.write('Congrats, you have earned the Silver Medal!'); } else if (correct>=1) { document.write('Congrats, you have earned the Bronze Medal!'); } else { document.write('Sorry, you earned no badge.'); }
4 Answers
gyorgyandorka
13,811 PointsHi! First: you can edit your post to format the code with proper indentation and syntax highlighting, like in my answer here. Click on the Markdown Cheatsheet link below the text box, there you'll find instructions!
There is a syntax error in your code, in the "Badges" section - a mistyped equal sign, and a closing parenthesis missing:
// you wrote if (correct=+=5 {
if (correct === 5) {
...
}
Now it should work :)
tuebuevv
Java Web Development Techdegree Student 3,769 PointsThis code work. note: if (correct=+=5 --> if (correct===5)
//quiz begins, no answers correct var correct= 0;
//Ask 5 questions var Question1= prompt('What language do they speak in Brazil?');
var Question2= prompt('What language do they speak in Spain besides Spanish?');
var Question3= prompt('What language do they speak in Portugal?');
var Question4= prompt('What language do they speak in Canada besides English?');
var Question5= prompt('What language do they speak in some parts of Haiti?');
//Correct corresponding answers
if (Question1.toUpperCase() === 'PORTUGUESE'){ correct +=1; } if (Question2.toUpperCase() === 'CATALAN'){ correct +=1; } if (Question3.toUpperCase() === 'PORTUGUESE'){ correct +=1; } if (Question4.toUpperCase() === 'FRENCH'){ correct +=1; } if (Question5.toUpperCase() === 'CREOLE'){ correct +=1; }
//Badges if (correct===5) { document.write('Congrats, you have earned the Gold Medal!'); } else if (correct>=3){ document.write('Congrats, you have earned the Silver Medal!'); } else if (correct>=1) { document.write('Congrats, you have earned the Bronze Medal!'); } else { document.write('Sorry, you earned no badge.'); }
Nick Trabue
Courses Plus Student 12,666 PointsI think the instructor made a mistake too even if you put exactly what he did. On his first question he correctly put
toUpperCase()
For the following questions the instructor put
toUpperCase
I did this as well, and it wouldn't run either.
Chris Ko
5,556 PointsGyorgy is correct. Once you fix the syntax error in the "Badges" section, your code runs fine. Again, that would be replacing "=+=" with "===" and adding the closing parenthesis.