Freecodecamp: === is not opposite of !==

Created on 22 Nov 2016  ·  13Comments  ·  Source: freeCodeCamp/freeCodeCamp


Challenge Name


https://www.freecodecamp.com/challenges/comparison-with-the-strict-inequality-operator

Issue Description


Actually !== is not the opposite of the strict equality operator. === means equal value AND equal type. !== means not equal value Or not equal type.That means if one condition is true then the expression will return true.But for strict equality operator both condition must be true.I think these information should be provided.

Browser Information

  • Browser Name, Version: Google Chrome,54.0.2840.99 m (64-bit)
  • Operating System: Windows 10
  • Mobile, Desktop, or Tablet: Desktop
help wanted

Most helpful comment

I possibly like the idea of adding the word 'logical' as in:

The strict inequality operator (!==) is the logical opposite of the strict equality operator.

And then perhaps we add an MDN link to the site above?

All 13 comments

It's not equal value and/or not equal type. See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators

I thinks the sentiment is still correct. But others can weigh in.

We could re-write the instructions to reflect the and/or nature of !==

Operand 1 | Operand 2 | State |
---------------|----------------|-----------|
'One String' | 'Another String' | true
1 | 2 | true
1 | '1' | true
4 | 4 | false
'String' | 'String' | false

@Bouncey but isn't !== the accepted opposite of ===? Or is there an alternative that I'm not aware of?

@dhcodes it is and it sort-of isn't

The issue is with this line in our challenge instructions

The strict inequality operator (!==) is the opposite of the strict equality operator.

Where the strict equality operator requires both type AND value to be equal to resolve as true, the strict inequality operator requires either the type OR the value to be different to resolve as true.

Describing it as the 'opposite' implys the type and value need to differ to reslove as true

We could reword the instructions to reflect the difference of the strict inequality operator

From a logic perspective, I think !== is the logical opposite of ===:
Assuming === can be written as Operand1 AND Operand2, then the opposite would be NOT(Operand1 AND Operand2). This can be written as NOT(Operand1) OR NOT(Operand2), which is the same as !==. However, I can see where the ambiguity is in the instructions and why that can be confusing.

I agree with @dhcodes and @robbawebba. While I was writing out my argumentation, Rob did a much better job. The only exception is NaN, which is not equal to itself.
I was writing a Codepen to assert (pun intended) my assumptions. In case anyone prefers code examples, here's my mess: http://codepen.io/Timoh/pen/ZBKBdL?editors=0012

I'm not opposed to changing it; I am just unsure what rewrite would accomplish this without making it more confusing for the camper. Thanks for the example @systimotic.

information removed

No longer contributing

I observed a lot of my friends do mistake in this logic.In most places people say !== is opposite of ===.So they assume the name of !== will be Not Equal value And Equal Type. as === is called Equal Value and Equal Type. Also in most cases learners are beginner so i think at least the name should be mentioned. It's just my suggestion.
http://www.w3schools.com/js/js_operators.asp

I possibly like the idea of adding the word 'logical' as in:

The strict inequality operator (!==) is the logical opposite of the strict equality operator.

And then perhaps we add an MDN link to the site above?

Yes.It is a good idea.....@dhcodes

If anyone wants to take this up, you'll need to add the word logical to the sentence:

The strict inequality operator (!==) is the opposite of the strict equality operator.

to make it:

The strict inequality operator (!==) is the logical opposite of the strict equality operator.

and modify the MDN Links file to add a reference to the link below and then add the MDN link to the challenge:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Non-identity_strict_inequality_(!)

Note: MDN links are not currently working on staging so mirror the code of other challenges with MDN links as there is no way to currently test locally.

I'd like to take this up, might need some help with the MDN links though, haven't done it before.

Was this page helpful?
0 / 5 - 0 ratings