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 trialVictor Gentile
4,996 PointsHow do I make the final message about which crown the user has won...
have written all of the code and it all works properly... can't seem to let the user know which if any of the crowns he/she has won?
11 Answers
Arturo Perez
Front End Web Development Techdegree Student 12,902 PointsIt's part of learning. On the last error just delet the alert(message); that should fix your integre problem.
Arturo Perez
Front End Web Development Techdegree Student 12,902 PointsYou should post the code so we can better help you:)
Victor Gentile
4,996 Pointsworkspaces won't let me copy anything... guess I should re-write the entire code..???here
Victor Gentile
4,996 Pointsvar correctAnswers = 0;
var input1 = prompt("How much is 7 - 3 ?"); if (parseInt(input1) === 4){ correctAnswers += 1; alert("That is the right answer."); } else { alert("Sorry. Your answer is incorrect."); }
var input2 = prompt("How much is 9 - 6 ?"); if (parseInt(input2) === 3){ correctAnswers += 1; alert("That is the right answer."); }else { alert("Sorry. Your answer is incorrect."); }
var input3 = prompt("How much is 8 - 4 ?"); if (parseInt(input3) === 4){ correctAnswers += 1; alert("That if the right answer."); }else{ alert("Sorry. Your answer is incorrect."); }
var input4 = prompt("How much is 5 - 1 ?"); if (parseInt(input4) === 4){ correctAnswers += 1; alert("That is the right answer."); }else{ alert("Sorry. Your answer is incorrect."); }
var input5 = prompt("How much is 7 - 6 ?"); if (parseInt(input5) === 1){ correctAnswers += 1; alert("That is the right answer."); }else{ alert("Sorry. Your answer is incorrect."); }
var message = correctAnswers; if (count === 0){ alert("You haven't won anything."); }else if (count >=1 && count <=2){ alert("You have won the Bronze Crown."); }else if (count >=3 && <=4) { alert("You have won the Silver Crown."); }else{ alert("You have won the GOLD CROWN !"); }
alert(message);
/* var message = "You have answered " + correctAnswers + " questions correctly.";
alert(message); */
Victor Gentile
4,996 Pointslol... this is not what it looks like on my workspace...
Arturo Perez
Front End Web Development Techdegree Student 12,902 PointsReplace The count with the correctAnswers variable, like this.
var message = correctAnswers; if (correctAnswers === 0){ alert("You haven't won anything."); } else if (correctAnswers >=1 && correctAnswers <=2){ alert("You have won the Bronze Crown."); } else if (correctAnswers >=3 && correctAnswers <=4){ alert("You have won the Silver Crown."); } else{ alert("You have won the GOLD CROWN !"); }
that should work since the correctAnswers is where your storing your correct answers. count should not be there since dose not seem like you have created a variable for it.
Victor Gentile
4,996 PointsThanks... I have tried that already... but I coded it again just as you suggested. I save the page and when I relaunch it in chrome... the page loads with the heading but no alert boxes appear... nothing. I've been trying to work around this for hours. Again, thank you... still tryin...
Victor Gentile
4,996 PointsJust tried it again... I had omitted one of the "correctAnswers" ... it's working now except after it runs the alert about which crown I've won... it gives another alert with just the integer. If its a gold crown, the alert goes away and another alert appears with just the number 5... weird.
Victor Gentile
4,996 PointsMost of my mistakes are oversights and spelling errors... gets frustrating... trying to slow down and check everything...
Arturo Perez
Front End Web Development Techdegree Student 12,902 PointsOn your silver crown else if statement, make sure your adding another correctAnswers variable to the argument like this correctAnswers<=4. You were missing a comparison on the code you first sent.
Victor Gentile
4,996 Pointsyes I caught that.... thanks for your time and consideration.
Arturo Perez
Front End Web Development Techdegree Student 12,902 PointsNo problem