Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Jonavan Helom
Jonavan Helom
2,593 Points

i don't get it, i'm stuck ; (

Can y'all tutor me on this, I don't get what I need to add. it keep say, "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."

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.");
}
if ( money || today) {
  alert("It's Friday, but I don't have enough money to go out")

}
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>

2 Answers

A great way to work though this question, because you will be doing this a lot in programming is to say the if statement out loud. I know it sounds silly, but it works. Here is an example:

if ( money >= 100 || today === 'Friday' ) {
  alert("Time to go to the theater"); 

english translation: if money is greater than or equal to 100 or today is Friday, then Time to go to the theater.

when you read that in english it sounds a little it funny "or today is Friday" since you're only going out on Fridays, it would make more sense to say "and today is Friday".

After we read it out in plain words, we just need to translate our syntax from or to and, and that is by using "&&"

if ( money >= 100 && today === 'Friday' ) {
  alert("Time to go to the theater"); 

now the above translates to:

if money is greater than or equal to 100 and today is Friday, then Time to go to the theater.

when your stating out learning syntax most times it's best to just say what you want to do. Then write what you want to do as a comment. This is commonly referred to as sudo code. It give a translation of what you are doing into english and helps you and programmers reading your code to understand it more clearly.

Bruh Moment
Bruh Moment
3,039 Points

I think it should be called pseudo-code.

Jeff Wilton
Jeff Wilton
16,633 Points

This challenge is a bit confusing but what you need to do is simply change all of the logical ORs to logical ANDs and the last else if to === 'Friday'. The ending script looks like this:

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