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 Inequality Operator

Comparison with the Inequality Operator


Problem Explanation

· Add the inequality operator != in the if statement so that the function will return "Not equal" when val is not equivalent to 99.


Hints

Hint 1

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


Solutions

Solution 1 (Click to Show/Hide)
// Setup
function testNotEqual(val) {
  if (val != 99) {
    // Change this line
    return "Not Equal";
  }
  return "Equal";
}

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

Code Explanation

The function first evaluates if the condition (val != 99) evaluates to true. 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").