Comparison operators, strict equality
How to solve it
You have to differentiate between basic equality (
==
) and strict equality (===
). Both operators check whether two values are equal. However, strict equality requires both values to have the same type. For example, the string '1'
and the number 1
are equal, but not strictly equal. Equality:
console.log('a' == 'b')
// output: false
console.log('a' == 'a')
// output: true
console.log('1' == 1)
// output: true
Strict Equality:
console.log('a' === 'b')
// output: false
console.log('a' === 'a')
// output: true
console.log('1' === 1)
// output: false