Please Help -- Control Flow, Comparison Operators II


#1

I am stuck in the Comparison Operators II exercise using === and !==.
https://www.codecademy.com/courses/learn-javascript/lessons/control-flow/exercises/comparison-operators-ii?link_content_target=interstitial_lesson

How do I use === or !== here?

var moonPhase = 'full';
  if (moonPhase) {
    console.log('Howwwlll!')
  } else {
    console.log('I swear I am not a werewolf...')
  };



#2

Hi @pyninja25060,

Previously you learnt to check for a condition using comparison operators:

var hungerLevel = 10;

if (hungerLevel > 7) {   //<==== this condition evaluates to "true" because hungerLevel (10) is more than 7
  console.log('Time to eat!');
} else {
  console.log('Let\'s eat later.');
}

So for your case here, it’s the same thing. Simply substitutes the === symbol in replace of the > (comparision symbol), and the value of 7 with the value of you wish to compare.

Let’s say:

var favoriteFruit = 'Apple';

if (favoriteFruit === 'Apple') { //<== this compares if favoriteFruit is equal to 'Apple'
    console.log('Yumm!');
} else {
    console.log('I need my favorite fruit.');
}

Note: notice where you should place your ; semicolon as well.

Cheers! :slight_smile:


#3

Thanks a lot! :slightly_smiling_face:


#4

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