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
Ayaz Sadiq
Courses Plus Student 5,361 PointsWhy is my super conditional challenge not working?
var money = 9; var today = 'Monday'
if ( money >= 100 || today === 'Friday' ) {
alert("Time to go to the theater");
} else if ( money >= 50 || today === 'Friday' ) {
alert("Time for a movie and dinner");
} else if ( money > 10 || today === 'Friday' ) {
alert("Time for a movie");
} else if ( money >= 5 || today === 'Friday' ) {
alert("It's Friday, but I don't have enough money to go out");
} else {
alert("This isn't Friday. I need to stay home.");
}
10 Answers
Stephen Van Delinder
21,457 PointsRight, right. So you need to do it without changing the variables. The or operators should be and operators and the last else if block should test if it is indeed Friday, but you have less than 10 money.
var money = 9;
var today = 'Friday'
if ( money >= 100 && today === 'Friday' ) {
alert("Time to go to the theater");
} else if ( money >= 50 && today === 'Friday' ) {
alert("Time for a movie and dinner");
} else if ( money > 10 && today === 'Friday' ) {
alert("Time for a movie");
} else if (today === 'Friday' ) {
alert("It's Friday, but I don't have enough money to go out");
} else {
alert("This isn't Friday. I need to stay home.");
}
Hope this helps.
Stephen Van Delinder
21,457 PointsAyaz,
This code seems to work as expected. What are you trying to accomplish?
var money = 9;
var today = 'Monday';
if ( money >= 100 || today === 'Friday' ) {
alert("Time to go to the theater");
} else if ( money >= 50 || today === 'Friday' ) {
alert("Time for a movie and dinner");
} else if ( money > 10 || today === 'Friday' ) {
alert("Time for a movie");
} else if ( money >= 5 || today === 'Friday' ) {
alert("It's Friday, but I don't have enough money to go out.");
} else {
alert("This isn't Friday. I need to stay home.");
}
Ayaz Sadiq
Courses Plus Student 5,361 PointsStephen,
According to the instructions, I have to run the code to where it states, "It's Friday, but I don't have enough money to go out." I'm on the last objective in the JavaScript Basics section. I was told I have to fix the code.
Stephen Van Delinder
21,457 PointsI'm not sure what to tell ya buddy. That's exactly what the code is doing for me as it is.
The only difference is that the sentence ends with a period.
Ayaz Sadiq
Courses Plus Student 5,361 PointsWhat was your code?
Stephen Van Delinder
21,457 Pointsvar money = 9;
var today = 'Monday';
if ( money >= 100 || today === 'Friday' ) {
alert("Time to go to the theater");
} else if ( money >= 50 || today === 'Friday' ) {
alert("Time for a movie and dinner");
} else if ( money >= 10 || today === 'Friday' ) {
alert("Time for a movie");
} else if ( money >= 5 || today === 'Friday' ) {
alert("It's Friday, but I don't have enough money to go out.");
} else {
alert("This isn't Friday. I need to stay home.");
}
Ayaz Sadiq
Courses Plus Student 5,361 PointsI think I made a mistake somewhere in the code.
Ayaz Sadiq
Courses Plus Student 5,361 PointsMaybe mine is not working because both of my conditions have to be true instead of just one of them.
Stephen Van Delinder
21,457 PointsWell, if that's the case, then you need to use an and && operator, not an or || operator.
Ayaz Sadiq
Courses Plus Student 5,361 PointsStephen,
Did you send me my code or yours?
Stephen Van Delinder
21,457 PointsI'm not sure what challenge you are on. I was just reading your code to see if it works.
Ayaz Sadiq
Courses Plus Student 5,361 PointsI did use an and operator.
Ayaz Sadiq
Courses Plus Student 5,361 PointsI'm on the Super Conditional Challenge under the section titled Making Decisions with Conditional Statements. It's in the JavaScript Basics section.
Ayaz Sadiq
Courses Plus Student 5,361 PointsThank you.