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

I ... don't know the answer to that question?

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."); }

script.js
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.");
}
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Well, part of the key to understanding this is in the question. It wants you to look at the money AND the day. This code if run now will produce the result "Time to go to the theater". Why is that? The conditional statement is looking at an OR expression. You can translate this to English as such: If I have over 100 (dollars) OR the day is Friday alert with "Time to go to the theater". Only one of those have to be true for that code to execute. Because the day is Friday you will get the "Time to go to the theater" alert.

What you want is the code that asks if both are true then execute the code. For example, if the day is Friday AND my money is less than ten then alert with a message "It's Friday, but I don't have enough money to go out." Hint: the AND operator in Javascript is &&.

Nicholas Grenwalt
Nicholas Grenwalt
46,626 Points

For this you need to get rid of the Logical Or operators ( '||' ) and replace them with Logical And operators ( '&&' ) so that it tests to make sure both conditions are true before giving back your answer. That should do the trick.

what does the !== mean?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

It means "not equal". In fact, you will hear many programmers refer to an ! as a "not operator". This is true for multiple programming languages.