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

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Super Conditional Challenge

Something's wrong with this script. The value in the variable money is only 9. But if you preview this script you'll see

this question confusing

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,716 Points

What is being asked is to change logical operators in order to get the correct output. In essence, you will need to change the logical flow of the conditional. The conditionals and the braces are critical to which blocks get executed.

Here's an example--

Suppose we were only supposed to go out on a Friday-- we need to use the '&&' operator to check money level AND the day of the week.

If money is greater than 40 AND the day is Friday, I can go to a nice restaurant. If money is greater than 10 AND the day is Friday, I can go to a fast food place. otherwise just stay at home and eat what's in the cupboard.

var money=2;
var today='Friday';
if (money > 40 && today=='Friday') {
    alert('Go out to a nice restaurant');
} else if (money > 10 && today=='Friday') {
    alert('Go out to a fast food place');
} else if (today =='Friday') {
    alert('You dont have enough money to go out, even though it is Friday eat mac and cheese. sadface');
} else {
     alert('It is not Friday... so stay home and eat whatever is in the cupboard');
}