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

Imran Chowdhury
Imran Chowdhury
5,684 Points

I don't know what I'm doing wrong in this last code challenge: "Something's wrong with this script...." Please help!

Can someone please take a look into my code changes and tell me what I'm doing wrong.

For some reason the first block of 'if' clause gets executed even after making changes to the whole code.

script.js
var money = 9;
var today = 'Friday'

if ( money !== 10 && 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' || money <= 9 ) {
  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>
Imran Chowdhury
Imran Chowdhury
5,684 Points

Thank you Cheo R for you help. I figured out what was wrong and made the adjustments. And I successfully passed the challenge! Cheer! THUMBS UP

1 Answer

Cheo R
Cheo R
37,150 Points

Hello Salman, your if statement is saying that if the variable today has the string Friday, that part of the statement is true; it also says if your variable money can make that part of the statement true as long as the variable is anything other than the integer 10.

var money = 9;
var today = 'Friday'

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

So assigning money as 9 would make that portion true and assigning today as Friday would make that portion of the statement true as well. Both being true makes the whole if statement true, executing that if clause.