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 trialImran Chowdhury
5,684 PointsI 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.
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.");
}
<!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>
1 Answer
Cheo R
37,150 PointsHello 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.
Imran Chowdhury
5,684 PointsImran Chowdhury
5,684 PointsThank 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