Why do I get a "false"?

First off, Im sorry for the visual pollution while asking this question. This is my first time using this forum and I haven’t quite understood how to do things yet…

Now, can anyone check the code bellow and explain me why I get “false” when I console.log it???

const plantNeedsWater = function(day){

if (day === ‘Wednesday’){

return true;

} else {

return false;

}

};

plantNeedsWater(‘Wednesday’);

console.log(plantNeedsWater());

===========
Im aware that by typing ‘Wednesday’ inside the last plantNeedsWater (last line), I get te desired answer (true). By why not in the code above?

When you console.log it you call it for a second time so you would need to put in ‘Wednesday’ again for it to print true. Also, don’t forget to format your code [How to] Format code in posts

1 Like

Hey, @digital9548981938!

This line is redundant because you are not assigning it to any meaningful variable nor do you output it. However, it’s the right thing to call. You should get rid of that next to last line and just simply run:
console.log(plantNeedsWater('Wednesday'));
Your final line doesn’t work because you are not passing ‘Wednesday’ as your parameter. That way the IF statement goes to ELSE right away since empty parameter does not equal to “Wednesday”.

Btw, if you want to, you can get help from the discobot. Just send him a message with the following content and he’ll teach you how to work the editor:
@discobot start New User

Hope it helps :smiley:

1 Like

to get the desired output that you are intending you need to assign
plantsNeedsWater('Wednesday') output to a variable eg:
const answer = plantsNeedWater('Wednesday')
-then you should be able to console.log(answer)

1 Like