I’m having a problem with the werewolf.js lesson 6/9 - Logical operators. It’s working somewhat, but not in the way that will allow me to go to the next lesson.
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
No error messages. I cannot get it to print the way the directions say. One place I’m having trouble is where they ask you to - 3. Now, change foggyNight to equal false and run it again.
Everything else checks out okay, green checkmarks next to each one.
```
var moonPhase = 'moonPhase';
var foggyNight = 'foggyNight';
if(moonPhase === 'full' && foggyNight === true) {
console.log('Howwwwlll!!!');
} else {
console.log('It is not out tonight');
}
From what I see, the place where you’re confused is when defining variables.
What I did was set var moonPhase equal to either ‘full’, or whatever else it told me to. The reason that you’re getting the message “It is not out tonight.” is because you set it to where if the moonPhase and the variable foggyNight are not full and true, respectively, then you are not going to howl.
Does this make sense?
The way you would fix this is by assigning the string ‘full’ to var moonPhase and the Boolean operator true to var foggyNight.
Let me know if this helps!
Okay, now that you’ve run it how it is, (your code is perfect by the way), change foggyNight to equal false. This should get you past the lesson.
Let me know, please!
Okay, so the reason that the console is printing Howwwwlll!!! still is because you changed the if condition. You want it to print ‘It is not out tonight’, so you want to keep the if conditions as foggyNight === true. The way you would write this is
if(moonPhase === ‘full’ && foggyNight)
Tell me how this works!
Okay, well instruction three was changing the variable foggyNight to false…
Oh I see what’s wrong!
Instead of printing ‘It is not out tonight’, make it say ‘Invalid moon phase’.
Tell me if this works!
WOO HOO! I’m glad! Thanks for being patient haha.
If you need any help in further questions, you can create a post and tag me using an @ and my user name.
You’re fine! I don’t personal message, so I won’t respond to your messages, but in a post, all you have to do is @kyleaw and it will notify me that I’ve been tagged.