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

multiple if else conditional statement

i am stuck with this question please help me to solve this question the error showing for this quiz is showing like this: It looks like there is at least one logical OR operator (that's the || symbols). Those test if just one of the conditions is true. kindly help me resolving this question

const money = prompt('enter your money');
const today =prompt('enter the day');

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<9 || today !== 'Friday' ) {
  alert("This isn't Friday. I need to stay home.");   
} else {
  alert("It's Friday, but I don't have enough money to go out.");
}
Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hello Samith,

We need to know what in particular you're struggling with please. :-) Let us know any error messages you're getting... anything that isn't happening that you're expecting to happen.

If you could also provide a link to the code challenge/question that would be useful too then we'll be able to help you with your query. Thanks. 😊

1 Answer

Hi Samith,

I'm not sure of the quiz, but from a logical perspective (assuming the alerts are accurate) the conditions should go...

if money is greater than or equal to 50 AND today is Friday, go to dinner & a movie
otherwise, if money is greater than or equal to 10 AND today is Friday, go to a movie
otherwise, if money is greater than or equal to 10 AND/BUT today is NOT Friday, don't go to a movie
otherwise, I must not have enough money to go out.

Again, the accuracy of that pseudo code is dependent on the accuracy of the alerts you want to show to the user.

Hope this helps.