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 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

Pure Beauty.

However this code is rather difficult to read. Could you post it in more readible form, please?

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!') }