Strict inequality doesn't work

Strict inequality doesn't work
0

#1

hello

i am running a simple function and i noticed the strict inequality doesn’t work.
i used a number - 3 and a string - “3”

 function tom (a){
               if(a !== 3){
                   return "yes";
               }
               return "no";
           }

            console.log(tom("3")); // returns yes although it should return no

#2

It’s doing as it should. '3' is strictly not equal to 3, so 'yes' is returned.


#3

yeah sub in a number instead of a string.


#4

The string “3” does not strictly equal (===) the number 3. If you would have used (==), then because of coercion, it would have been equal. Like Kevcomedia said, “its doing as it should.”


#5

Thanks man, i was confused…