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
Daniel Springer
Courses Plus Student 5,090 PointsHere my Solution! Try it out and let me know what you think!
// Welcome msg
alert("Welcome to the Beginners JavaScript Quiz");
// Players score
var score = 0
// Question / Answer 1
var answer1 = prompt( "What is the \"===\" operator called?\n\n1= super equal sign,\n2= very equal symbol,\n3= strict equality operator.");
// Question / Answer conditional evaluation
if (answer1 === "3"){
alert("That was correct");
score += 1;
alert("Your score is " + score + " point");
} else {
alert("That was not correct");
}
var answer2 = prompt("When using the && operator both conditions must be true for the condition to return true\n\n1= false,\n2= true.")
if (answer2 === "2"){
alert("That was correct");
score += 1;
alert("Your score is " + score + " points");
} else {
alert("That was not correct");
}
var answer3 = prompt("What would be the result of 3+2+”7″?\n\n1= 10,\n2= 327,\n3= 57.")
if (answer3 === "3"){
alert("That was correct, Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.");
score += 1;
alert("Your score is " + score + " points");
} else {
alert("That was not correct");
}
var answer4 = prompt("What is not a Pop up type in JavaScript?\n\n1= Alert,\n2= Prompt,\n3= Message.")
if (answer4 === "3"){
alert("That was correct!");
score += 1;
alert("Your score is " + score + " points");
} else {
alert("That was not correct");
}
var answer5 = prompt("What is not a JavaScript Data type:\n\n1= Number,\n2= String,\n3= Boolean,\n4= Script.")
if (answer5 === "4"){
alert("That was correct, Script is not a data type");
score += 1;
alert("Your score is " + score + " points");
} else {
alert("That was not correct");
}
// Crown evaluation
if (score === 5){
document.write("<h2>You got a Gold Crown</h2>")
} else if (score === 4 || score === 3){
document.write("<h2>You got a Silver Crown</h2>")
} else if (score === 2 || score === 1){
document.write("<h2>You got a Bronce Crown</h2>")
} else {
document.write("<h2>You got no Crown, keep practicing!</h2>")
}
Daniel Springer
Courses Plus Student 5,090 PointsHi Steve, noted. Thanks for the advise. Hope it is better now.
1 Answer
Steven Parker
243,331 PointsMuch better after formatting, otherwise you can get unintended syntax errors (and it's not nearly as pretty).
That's a cute variation of the basic program, and it works well, good job.
And it was so funny I might start calling that operator the "very equal symbol".
Daniel Springer
Courses Plus Student 5,090 Pointshahaha, had to come up with something, it looks definitely very equal to me ? ! Thanks for checking it out and leaving your comment, much appreciate it. Regards, Dan
Steven Parker
243,331 PointsSteven Parker
243,331 PointsWhen posting code to the forum, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area.
Or watch this video on code formatting.