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

I am posting my code for some feedback

let correctResponses = 0

let question1 = prompt('What is Aquaman\'s real name?') let question2 = prompt('What is Superman\'s real name?') let question3 = prompt('What is Cyborg\'s real name?') let question4 = prompt('What is Wonder Woman\'s real name?') let question5 = prompt('What is The Flash\'s real name?')

if(question1.toUpperCase() === 'ARTHUR CURRY') { correctResponses +=1 }

if(question2.toUpperCase() === 'CLARK KENT') { correctResponses +=1 }

if(question3.toUpperCase() === 'VICTOR STONE') { correctResponses +=1 }

if(question4.toUpperCase() === 'DIANA PRINCE') { correctResponses +=1 }

if(question5.toUpperCase() === 'BARRY ALLEN') { correctResponses +=1 }

alert('You have answered ' + correctResponses + ' questions correctly.');

if(correctResponses === 5) { alert('Congratulations, you have earned a GOLD crown!') } else if (correctResponses >= 3) { alert('Well done, you have earned a SILVER crown!') } else if (correctResponses >= 1) { alert('Well done, you have earned a BRONZE crown!') } else { alert('You had ' + correctResponses + ' correct answers. Try harder!') }

2 Answers

You're right...I will repost it.

Don't know why it came out that way

let correctResponses = 0

let question1 = prompt('What is Aquaman\'s real name?') let question2 = prompt('What is Superman\'s real name?') let question3 = prompt('What is Cyborg\'s real name?') let question4 = prompt('What is Wonder Woman\'s real name?') let question5 = prompt('What is The Flash\'s real name?')

if(question1.toUpperCase() === 'ARTHUR CURRY') { correctResponses +=1 }

if(question2.toUpperCase() === 'CLARK KENT') { correctResponses +=1 }

if(question3.toUpperCase() === 'VICTOR STONE') { correctResponses +=1 }

if(question4.toUpperCase() === 'DIANA PRINCE') { correctResponses +=1 }

if(question5.toUpperCase() === 'BARRY ALLEN') { correctResponses +=1 }

alert('You have answered ' + correctResponses + ' questions correctly.');

if(correctResponses === 5) { alert('Congratulations, you have earned a GOLD crown!') } else if (correctResponses >= 3) { alert('Well done, you have earned a SILVER crown!') } else if (correctResponses >= 1) { alert('Well done, you have earned a BRONZE crown!') } else { alert('You had ' + correctResponses + ' correct answers. Try harder!') }