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 trialShivang Chaturvedi
2,600 PointsHere's my code
var quesCount = 5; var correctAnswer = 0; var score = 0; quesCount -= 1; var ques1 = prompt("What is your name? " + "Questions Left: " + quesCount); ques1 = ques1.toUpperCase();
if(ques1 === "SHIVANG")
{ correctAnswer +=1; score = score + 20; alert("You are right. Your score is: " + score); }
else { correctAnswer = correctAnswer; score = score; alert("Don't remember your name? Seems like you have short team memory.."); }
/Question 2/ quesCount -= 1; var ques2 = prompt("What is your city? " + "Questions Left: " + quesCount); ques2 = ques2.toUpperCase();
if(ques2 === "MEERUT")
{ correctAnswer +=1; score += 20; alert("You are right. Your score is: " + score); }
else { correctAnswer = correctAnswer; score = score; alert("Don't remember your city? It's gotten better since you left.. Current score: " + score); } /Question 3/ quesCount -= 1; var ques3 = prompt("What is your dog's name? " + "Questions Left: " + quesCount); ques3 = ques3.toUpperCase();
if(ques3 === "BOZO")
{ correctAnswer +=1; score += 20; alert("Great!! You remember your dog's name. Your score is: " + score); }
else { correctAnswer = correctAnswer; score = score; alert("Please don't tell me that you killed your dog. Current score: " + score); }
/Question 4/
quesCount -= 1; var ques4 = prompt("Where's your school located? " + "Questions Left: " + quesCount); ques4 = ques4.toUpperCase();
if(ques4 === "PUNE")
{ correctAnswer += 1; score += 20; alert("Ohh! I am glad that you went to school. Your score is: " + score); }
else { correctAnswer = correctAnswer; score = score; alert("That's precisely why you should visit your school at least once in a year. Current score: " + score); }
/Question 5/
quesCount -= 1; var ques5 = prompt("What is native language? " + "Questions Left: " + quesCount); ques5 = ques5.toUpperCase();
if(ques5 === "HINDI")
{ correctAnswer += 1; score += 20; alert("Hindi is a great laungauge. Your score is: " + score); }
else { correctAnswer = correctAnswer; score = score; alert("You are amazing!! Where are you from... Mars? Current score: " + score); }
if(correctAnswer ==5) { document.write("<h2> Your final score is: " + score + ". You have answered " + correctAnswer + " questions correctly.</h2>") alert("You have won a Golden Crown"); } else if(correctAnswer == 3 || correctAnswer == 4) { document.write("<h2> Your final score is: " + score + ". You have answered " + correctAnswer + " questions correctly.</h2>") alert("You have won a Silver Crown"); }
else if(correctAnswer == 1 || correctAnswer == 2)
{
document.write("<h2> Your final score is: " + score + ". You have answered " + correctAnswer + " questions correctly.</h2>")
alert("You have won a Bronze Crown");
}
else { alert("You have won nothing my friend"); }
Steven Parker
231,236 PointsSteven Parker
231,236 PointsYep, that looks like some code alright.
But seriously...
When posting code, be sure to format it using the instructions from the Markdown Cheatsheet found below the "Add an Answer" area
Or even better, make a snapshot of your workspace and post the link to it. This allows others to try out your example and provide a more complete and accurate answer.
Also, it's not clear if you're asking a question here about the code. Please elaborate a bit more.