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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Marvin Müller](https://uploads.teamtreehouse.com/production/profile-photos/10599866/micro_Marvin.jpg)
Marvin Müller
8,884 PointsCoding challenge "making decisions with conditional statements" keeps telling me it's wrong despite the right output
Hey guys, So I'm stuck at the very last challenge of the conditional statements-part of the javascript basics course. Even though I get the expected output right , it keeps telling me that something is wrong. After I got it checked by the TH-Team , which told me everything is fine with the challenge itself, i wondered if you could help.
The programm wants you to check why it gets the message "Time to go to the theater" even thought it should get "It's Friday, but I don't have enough money to go out". So here is my code:
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 ( money <= 10 || 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.");
}
Even though I get the right message, I get this Bummer: Bummer: Hmm. Looks like there is at least one logical OR operator -- that's the || symbols. Those test if just one of the conditions are true.
anyone can tell me what I'm doing wrong? I changed the || operators in the first few if else loops to && , because it would always put out the "Time to go to the theater" message because the var today is set on Friday.
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYou get the right output when you test on "Friday", but the code needs to give a different response for other days.
You're close, but you still have work to do on this line:
} else if ( money <= 10 || today !== 'Friday' ) {
alert("It's Friday, but I don't have enough money to go out");
Paraphrasing the message: "It's Friday and I don't have enough money..." gives you a clue that there are two errors in the logic:
- the conditions should be combined with the AND operator (
&&
) to make sure both are true - it should be testing that today is Friday instead of not Friday.
Marvin Müller
8,884 PointsMarvin Müller
8,884 PointsI made it THANK YOU :). Yea I wasn't thinking about "if its not friday-thing".
Nice clues you gave me - now I could complete and get the badge :)
Steven Parker
230,688 PointsSteven Parker
230,688 Points