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 trialScott Hunt
1,100 Points|| question
I seem to be stuck on this quiz regardless of the fact that I feel I have met the challenge.
It wants you to configure the code to where you get the answer It's Friday, but I don't have enough money to go out.
I made all of the days !== Friday in the "If" and the first two "Else If" statements and made the last "Else If" days ===Friday. Though the dialog box gave me the answer I as asked to give it kept giving me the "Bummer at least one of the || operators is logical"...I can't figure out why.
I also changed the variable to 'Monday' which also gave me the correct dialog box but the same message as listed above.
2 Answers
Jacob Mishkin
23,118 PointsWhat about using the and "&&" operator in those conditional statements?
Samy Basset
11,862 PointsThe operators in the challange are all || (or), you need to use the && operators(and).
the variables are: money = 9; today = 'Friday';
e.g.
if(money > 10 || today === 'Friday')
So it says if one of the two variables match the code in the if gets executed. Because today is true, the code in the if runs.
In this case they both need to be true, so if we change the ||(or) to &&(and) the if statement goes as followed:
if(money > 10 && today == 'Friday')
both of the variables need to match, money is less than 10 so this is false, today is true. But because both of the variables needs to be true, the code block doesn't get executed.