This appears to be working but operates not as well


#1

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.


https://codecademy.com/courses/learn-javascript/lessons/control-flow/exercises/logical-operators?action=lesson_resume&link_content_target=interstitial_lesson


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');
}

The message I get is - It is not out tonight


#2

If the instructions are to change foggyNight to equal false, you haven't done so yet.


#3

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! :slight_smile:


#4

Here is the code I got to use to make it howl:

var moonPhase = 'full';
var foggyNight = true;
if(moonPhase === 'full' && foggyNight === true) {
console.log('Howwwwlll!!!');
} else {
console.log('It is not out tonight');
}

And here's the reply I got:

Howwwwlll!!!

If this is all correct, I need to move on to the next lesson, which it is not currently allowing me to do.


#7

Lesson 6/9 in werewolf.js

https://codecademy.com/courses/learn-javascript/lessons/control-flow/exercises/logical-operators?action=lesson_resume&link_content_target=interstitial_lesson


#8

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! :smile:


#9

Here is the change to false:

var moonPhase = 'full';
var foggyNight = false;
if(moonPhase === 'full' && foggyNight === false) {
console.log('Howwwwlll!!!');
} else {
console.log('It is not out tonight');
}

Here's the reply I got:

Howwwwlll!!!

Still will not move to the next lesson.


#10

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!


#11

Here it is, again. I'm sorry I have to keep bugging you about this:

var moonPhase = 'full';
var foggyNight = false;
if(moonPhase === 'full' && foggyNight === true) {
console.log('Howwwwlll!!!');
} else {
console.log('It is not out tonight');
}

The reply is:

It is not out tonight

I still cannot advance to the next lesson.


#12

Don't worry about bugging me! On the left part of the screen, how many of the instructions are checked off and green?


#13

Instructions 1 and 2 are checked off in green, instruction 3 is red with an x.


#14

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!


#15

It worked. Thanks Kylea. :joy:


#16

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. :slight_smile:


#17

Kylea:

I'm not sure about how to create a post and then tag you using an @ and
your user name.

I hope you don't get upset with me - I sent two redundant messages about
random.js, lesson 8/9.


#18

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. :slight_smile:


#19

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.