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

Feedback

Please give feedback on my code:

var a = prompt("What is number 1?")
var b = prompt("What is number 2?")
var c = prompt("What is number 3?")
var d = prompt("What is number 4?")
var e = prompt("What is number 5?")

var answer1 = "1"
var answer2 = "2"
var answer3 = "3"
var answer4 = "4"
var answer5 = "5"

var answers=0

//var player = ''

if (a===answer1) {
    answers=answers+1

}

if (b===answer2) {
    answers=answers+1

}

if (c===answer3) {
    answers=answers+1

}

if (d===answer4) {
    answers=answers+1

}

if (e===answer5) {
    answers=answers+1

}

if (answers===5) { player='gold'} else if (answers===3 || answers===4)
    {player="silver"} else if (answers === 1 || answers ===2) {player="bronze"} else {player="no"}

document.write("You answered " + answers + " correctly. You have a " + player + " crown.")

1 Answer

Steven Parker
Steven Parker
231,275 Points

Good job on the coding. :+1:

But I might suggest making the questions a little bit more challenging! :laughing:

ha, good point 🤣