If statement exercise

Create an if statement that will evaluate if the weather is rainy and you’re feeling happy. If so, in the code block of the if statement, print the string “I am singing in the rain, just singing in the rain!”.

  1. var weather = ‘rainy’;
  2. var isHappy = true;
  3. if (weather !== isHappy) {console.log(‘I am singing in the rain, just singing in the rain!’);}
  4. console.log();

outcome:

Code is incorrect
You should check weather and isHappy in your condition

What I am doing wrong???

The variable weather contains a string and the variable isHappy contains a boolean so you don’t want to compare them directly. You want to check if the weather is rainy AND you’re feeling happy. Hopefully that is a big enough of a clue to steer you in the right direction.

I definitely help but I still couldn’t solve it.

Because now says : Unknown error :confused:

 if (weather === 'rainy' && isHappy === true); {console.log('I am singing in the rain, just singing in the rain!');}

You do have the if condition working correctly now but you’ve added something that you definitely do not need after the parens. I don’t think your if statement needs to be winking at you :wink:

1 Like

If you format your code differently then you might be able to see the issue after the if statement a little better.

const weather = "rainy";
const isHappy = true;
if (weather === "rainy" && isHappy);{
  console.log("I am singing in the rain, just singing in the rain!");
}

Hope that helps!

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