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

maya sophie
maya sophie
5,754 Points

when checking work is saying "Bummer:....", but if use preview I get the correct mesage .

when checking work is saying "Bummer:....", but if I use preview I get the correct mesage .

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

Kevin Gates
Kevin Gates
15,052 Points

With this as the original code:

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

The way you get the "It's Friday, but I don't have enough money to go out" phrase is to change your OR conditionals to AND conditionals.

Also, you need to have the inverse function. So not today !=='Friday' but the opposite.

maya sophie
maya sophie
5,754 Points

Thanks Kevin...I did that...I was just wondering why is not saying something like:"...also corect but you should change the or to and..."Because the way I did is also giving me the corect answer.

Kevin Gates
Kevin Gates
15,052 Points

Hi maya sophie ,

Your answer isn't fully correct. And they have parsers to determine if you're working through the question thoroughly. The correct answer is this (and I checked):

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

Do you see the differences between what I put here and your original answer?

maya sophie
maya sophie
5,754 Points

Yes that's the code should be on the console ,I've already did that.......with 1 correction: today === 'Friday' not today== 'Friday'.. I lunched all this discussion to ask if there are alternative ways to run the code and get the same result( because I've checked in Brackets and it was also running different code with same result. Anyways, it's great to see people get help in learning..thx a lot for answers.

Kevin Gates
Kevin Gates
15,052 Points

Yes, there are ways other than the above to test this and get the results. But their parser to check your answers is expecting a specific setup.