Help me! In section of Comparison Operators


#1

Hello, I am Steven. A new guy just starts to learning Javascript. I am looking forward to asking some expert to help out.

Appreciate that.


var hungerLevel = true / false;
if (hungerLevel > 7) {
console.log('Time to eat!');
} else { (hungerLevel < 7)
console.log('Let\'s eat later.');
}


Replace this line with your code.


#2

Instructions:
1.Write a variable named hungerLevel and set it equal to 5.

var hungerLevel = true / false; // wrong

here you created a variable named hungerLevel but you have to set it equal to 5. for example if i want to set a variable named x equal to 10 . i would do like

var x=5

next

if (hungerLevel > 7) {
console.log('Time to eat!');
} else { (hungerLevel < 7)
console.log('Let\'s eat later.');
}

first of all else is not allowed to have a condition and now
here you first checked
if (hungerLevel > 7)
so if it is true then
console.log('Time to eat!');

and if its false then the else's code block runs.that is

else {
  console.log('Let\'s eat later');
}

so dont need to change anything in the code what you are not told.just do step by step what instructions say .


anything you want to know you can ask freely :slight_smile:


#3

Really appreciate your feedback.

I did the way that you instructed me to do so. However, it still does not work.

How come?

var hungerLevel = 5;
if (hungerLevel > 7) {
console.log('Time to eat!');
} else { (hungerLevel < 7)
console.log('Let\'s eat later.');
}


#4

what did i say?

i said else is not allowed to have a condition. so remove (hungerLevel < 7) inside else statement

should be

else {
  console.log('Let\'s eat later');
}

now come to the point .
did you complete your instruction(number 3)?

set the hungerLevel variable equal to 10 and run your code again.


#5

Yeah! I did it successfully by following your instructions!

Can't be exciting anymore.

Thank you, dude!


#6

I have one more question,

var moonPhase = 'true';

if (moonPhase === 'full' && foggyNight === true) {
console.log('Howwwwlll!!');
} else if (moonPhase === 'mostly full') {
console.log('Arms and legs are getting hairier');
} else if (moonPhase === 'mostly new') {
console.log('Back on two feet');
} else {
console.log('Invalid moon phase');
}

In Logical Operators, How can I make it work ?

The instruction says :

Let's say the werewolf can only become its wolf form when there is a full moon and a it's a foggy night.

We already have a moonPhase variable, so let's start with making a foggyNight variable set equal to true.


#7

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