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 trialRafał Stasiak
3,763 PointsHello, after pop out questiones boxes fucnction document.write doesnt show up with current score.
var userscore = 0; var firsquestion = prompt("Does Poland belongs to EU?"); if (firsquestion === "Yes" || firsquestion ==="yes") { userscore += 1; } var secondquestion = prompt("The Capital of Poland"); if (secondquestion === "Warsaw") { userscore += 1; } var thirdquestion = prompt("Is Floryda located in USA"); if (thirdquestion === "Yes"|| thirdquestion=== "yes"){ userscore += 1; } var fourthquestion = prompt("Current year"); if (parseInt.fourthquestion === 2019) { userscore += 1; } var fifthquestion = prompt("Capital of Spain"); if (fifthquestion=== Madrit){ userscore += 1; } document.write("<p>You got " + userscore + " out of 5 questions correct.<p>");
if(userscore === 5){ alert ("You have golden crown"); } else if (userscore >= 3){ alert ("You have silver crown");
} else if (userscore >=1){ alert ("You have brown crown"); } else { alert("Sorry, try next time"); }
2 Answers
Steven Parker
231,898 PointsDuring the fifth question, the program encounters an error because the term Madrit
is not defined. This is probably intended to be a literal string and should be enclosed in quotes (and also check the spelling!).
Otherwise, the score total seems to be correctly reported but won't appear until the final pop-up is closed (which is normal).
Also, the fourth question cannot be correct because the a type-sensitive comparison (===) is being used to match a string with a number. You may have also meant to enclose 2019
in quotes.
Rafał Stasiak
3,763 PointsThank you, know its working.