Comparison with the Inequality Operator - Notes Question

This isn’t a question about the code. My question is about the example given.

0 != false //false

0 does not equal false so what would that return false on an inequality unless we are talking 1s and 0s as a computer programming language as on and off, but with no special notation I would assume that a 0 is just a 0 in JS unless notated otherwise. However, I am lead to believe that binary is interchangeable with basic 1s and 0s in JS since this was the line above it:

1 != true //false

I am new so I could be wrong. Can anyone please explain the meaning behind these examples?

Your code so far

// Setup
function testNotEqual(val) {
  if (val != 99) { // Change this line
    return "Not Equal";
  }
  return "Equal";
}

// Change this value to test
testNotEqual(99);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/comparison-with-the-inequality-operator

If you convert 0 to a boolean (and that is what happens when you use some kind of comparator) it will return false.

1 Like