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've tried many ways but wont work.

I am not understanding this error message, even i've tried many ways and none of them help.

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 === 'fFriday' ) {
  alert("Time for a movie and dinner");    
} else if ( money > 10 || today === 'friday' ) {
  alert("Time for a movie");   
} else if ( today === 'Friday' || money > 10) {
  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>

2 Answers

Hi Raja,

The challenge is asking you to fix the mistakes in the script. Money is 9 and today is friday so the message should say:

"It's Friday, but I don't have enough money to go out".

So, first error i come across is that there are "OR" operators in there that check whether one of the conditions is true. You want to check if they are both true thought so you need an "AND" operator whereever you see an "OR". So, i changed all || to && to check whether both conditions are true, so you can go out and do something.

Next, we get to the last "else if" And that is is checking if it is NOT friday today and you want it to check if it IS friday today. So you change !== to ===.

Last, but not least. Make sure you write the strings correct. I saw a "fFriday" in there somewhere. :)

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

Good luck,

Elian

Thanks Elian for your solution, I intentionally changed the strings to make the conditional statement as false, the main objective of this challenge is to get the desired alert i.e.(It's Friday, but I don't have enough money to go out). This challenge has multiple solutions to get the output, i've tried many but not this. I was getting a confusion to understand the hint. Thanks again Elian.

Regards, Rajashekar

Justin Kraft
Justin Kraft
26,327 Points

Make sure your string variable 'Friday' is consistent throughout each conditional statement. You'll also want to replace OR (||) with AND (&&) and also the last else if, check if money is less than 10