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 trialTushar Singh
Courses Plus Student 8,692 PointsWhy my code is not working?
var correct = 0;
var string_ques1 = prompt("How many Continents are there in the world?");
var ques2 = prompt("Largest continent in the world?");
var string_ques3 = prompt("How many Oceans are there in the world?");
var ques4 = prompt("What is the capital of Australia?");
var ques5 = prompt("Which is the longest river in the world");
ques1 = parseInt(string_ques1);
ques3 = parseInt(string_ques3);
if (ques1 ==== 7) {
correct +=1
}
if (ques2.toUpperCase ==== 'ASIA') {
correct +=1
}
if (ques3 ==== 5) {
correct +=1
}
if (ques4.toUpperCase ==== 'CANBERRA') {
correct +=1
}
if (ques5.toUpperCase ==== 'NILE') {
correct +=1
}
document.write("<p>You got " + correct + " out of 5 questions correct.</p>");
if (correct === 5) {
document.write("Gold Crown");
} else if (correct >= 3) {
document.write("Silver Crown");
} else if (correct >= 1) {
document.write("Bronze Crown");
} else {
document.write("duh !You are good for nothing.");
}
What am I doing wrong here?
Or is it necessary to add IF statements when I defined the variables??
1 Answer
Tom Sager
18,987 Points"Not working" doesn't tell anyone what behavior you are seeing. What does the code do (or not do)? Are you getting any error messages?
Not that there is no such operator as "====". You might start there.