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

Chetan Shah
Chetan Shah
649 Points

Conditional challenge

var answers = 0; var answers1 = 0; var answers2 = 0; var answers3 = 0; var answers4 = 0; var answers5 = 0;

var questionOne = prompt("What is the capital of India?"); if (questionOne.toUpperCase() === 'DELHI'){ answers1 = answers + 1; }

var questionTwo = prompt("What is the national animal of India?"); if (questionTwo.toUpperCase() === 'TIGER'){ answers2 = answers1 + 1;

}

var questionThree = prompt("Who is the PM of India?"); if (questionThree.toUpperCase() === 'NARENDRA MODI'){ answers3 = answers2 + 1;

}

var questionFour = prompt("What is the national game of India?"); if (questionFour.toUpperCase() === 'HOCKEY'){ answers4 = answers3 + 1;

}

var questionFive = prompt("Name of your country?"); if (questionFive.toUpperCase() === 'INDIA'){ answers5 = answers4 + 1; document.write('Answers correct '+answers5); }

var number1 = 1; var number2 = 2; var number3 = 3; var number4 = 4; var number5 = 5;

if (parseInt(answers5) == number5 ){ document.write('you won gold'); }

if (parseInt(answers5) == number4 || number3 ){ document.write('you won silver'); }

if (parseInt(answers5) == number2 || number1 ){ document.write('you won bronze'); }

Steven Parker
Steven Parker
231,236 Points

Do you have a question, or an issue you need help with regarding this code?