Exercise: Learn JavaScript / Control flow / Chapt. 5


#1

Hi guys,

I have a question about the exercise below (learn JavaScript / Control flow / 5)

let hungerLevel = 5;
if (hungerLevel > 7) {

console.log(‘Time to eat!’);
} else {
console.log(‘We can eat later!’)}

This code produces: We can eat later.

However, when I change ‘> 7’ to ‘=10’ it produces ‘Time to eat!’.

I am confused now, because hungerLevel is nog greater than 7, and is also not equal to 10.
So what is up with this?

Thanks in advance!


#2

= assign in javascript, it doesn’t check if values are equal.


#3

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