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

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

Jieni Hou
Jieni Hou
5,136 Points

My Solution to the question

Here's My Solution:

`javascript

alert(" This is a quiz to evaluate your IQ. You have 5 questions to answer.");

// first question var q1 = prompt("Question 1: What is the capital city of Canada?"); var answer1 = 'ottawa'; var count = 0;

if (q1.toLowerCase() === answer1){ count += 1; }

// second question var q2 = prompt("Question 1: What is the capital city of Singapore?"); var answer2 = 'singapore';

if (q2.toLowerCase() === answer2){ count += 1; }

// third question var q3 = prompt("Question 1: What is the capital city of USA?"); var answer3 = 'washington';

if (q3.toLowerCase() === answer3){ count += 1; }

// forth question var q4 = prompt("Question 1: What is the capital city of Thailand?"); var answer4= 'bangkok';

if (q4.toLowerCase() === answer4){ count += 1; }

//fifth question var q5 = prompt("Question 1: What is the capital city of Korea?"); var answer5 = 'Seoul';

if (q5.toLowerCase() === answer5){ count += 1; }

// check for scores if (count === 5){ alert("Congratulations! You've won a Gold Medal!"); } else if (count === 4 || count === 3){ alert("You've won a silver medal!"); } else if (count === 2 || count === 1){ alert("You've won a bronze medal! Better luck next time!"); } else{ alert("You've won nothing. You lose."); } `