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
Omar Farag
4,573 PointsIf condition not working
I used this if condition but it ain't working
alert("Here we go");
var agree = prompt("Are you ready?");
console.log("Variable created");
if (agree.toUpperCase === "YES" || agree.toUpperCase === "Y") {
// Quiz code
console.log("Hello");
alert("Condition passed");
}else {
alert("Okay. Refresh the page if you change your mind.");
}
2 Answers
Steven Parker
243,656 PointstoUpperCase is a function. To call a function, you have to include the parentheses () after it, whether you are passing arguments or not. Without the parentheses, you are just naming the function.
Omar Farag
4,573 PointsYep, but sometimes I feel stupid. Thanks though!
Omar Farag
4,573 PointsOmar Farag
4,573 PointsThanks. That's 4 stupid mistakes I've done so far...
Steven Parker
243,656 PointsSteven Parker
243,656 PointsMistakes are not stupid. They are valuable learning opportunities.
Speaking of mistakes, ignore what I said about "YES", I was thinking you were just checking the first letter.