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
claudius mainja
9,661 Pointsjavascipt methods and the output results
hie can someone help me on this code and tell me if my program is wrong ...
/*conditional statements */
var question = prompt ("what is my name?");
if (question.toUppperCase() ==="CMA") {
document.write("<p>That's right, you are good!</p>");
}
var question1 = prompt ("what is my favourate song?");
if (question1.toUppperCase() ==="Prayer") {
document.write("<p>That's right, you are good!</p>");
correct+=1
}
var question2 = prompt ("what is my girls name?");
if (question2.toUppperCase() ==="Shalom") {
document.write("<p>That's right, you are good!</p>");
correct+=2
}
var question3 = prompt ("why are you answering me");
if (question3.toUppperCase() ==="dreams") {
document.write("<p>That's right, you are good!</p>");
correct+=3
}else {
document.write("<p>Ohhh No you are wrong pliz try again </p>");
}
thats the code i am trying to create a quiz program at the same time placing the output declaration ... help me
2 Answers
Julian Gutierrez
19,325 PointsA couple of issues after a quick look.
- There is a typo in toUpperCase(), you have one too many letter p in your example.
- Since you are using to toUpperCase() your checks have to be capitalize, look at the example below.
// Your Example
question1.toUppperCase() ==="Prayer"
// You Should be comparing it to "PRAYER"
question1.toUppperCase() === "PRAYER"
- You are using the variable "correct" but have not declared it.
claudius mainja
9,661 Pointsthank you julian for helping me didn't notice that ...
Julian Gutierrez
19,325 PointsJulian Gutierrez
19,325 Points*Markdown edited - JG