Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Rafał Stasiak
Rafał Stasiak
3,763 Points

Hello, 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
Steven Parker
216,096 Points

During 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
Rafał Stasiak
3,763 Points

Thank you, know its working.