Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

1.2 KiB

title
title
Comparison with the Strict Inequality Operator

Comparison with the Strict Inequality Operator


Problem Explanation

· Add the strict inequality operator to the if statement so the function will return "Not Equal" when val is not strictly equal to 17.


Hints

Hint 1

The strict inequality operator (!==) will return true if the first value is not equal to the second one taking value type into consideration.


Solutions

Solution 1 (Click to Show/Hide)
function testStrictNotEqual(val) {
  if (val !== 17) {
    return "Not equal";
  }
  return "Equal";
}

// Change this value to test
testStrictNotEqual(10);

Code Explanation

The function first evaluates if the condition (val !== 17) evaluates to true considering both value and value type. If it does, it returns the statement between the curly braces ("Not equal"). If it doesn't, it returns the next return statement outside them ("Equal").