Strict inequality doesn't work


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

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


yeah sub in a number instead of a string.

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.”

Thanks man, i was confused…