Files
HenMoshe ea416b6dc2 fix(curriculum): add result of comparison expression evaluation to the inline comment (#45224)
* Add result of comparison expression evaluation in the inline comment #45183

* Apply suggestions from code review

thanks!

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
2022-02-23 18:58:42 +01:00

1.6 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244d1 Comparison with the Strict Equality Operator 1 https://scrimba.com/c/cy87atr 16790 comparison-with-the-strict-equality-operator

--description--

Strict equality (===) is the counterpart to the equality operator (==). However, unlike the equality operator, which attempts to convert both values being compared to a common type, the strict equality operator does not perform a type conversion.

If the values being compared have different types, they are considered unequal, and the strict equality operator will return false.

Examples

3 ===  3  // true
3 === '3' // false

In the second example, 3 is a Number type and '3' is a String type.

--instructions--

Use the strict equality operator in the if statement so the function will return the string Equal when val is strictly equal to 7.

--hints--

testStrict(10) should return the string Not Equal

assert(testStrict(10) === 'Not Equal');

testStrict(7) should return the string Equal

assert(testStrict(7) === 'Equal');

testStrict("7") should return the string Not Equal

assert(testStrict('7') === 'Not Equal');

You should use the === operator

assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);

--seed--

--seed-contents--

// Setup
function testStrict(val) {
  if (val) { // Change this line
    return "Equal";
  }
  return "Not Equal";
}

testStrict(10);

--solutions--

function testStrict(val) {
  if (val === 7) {
    return "Equal";
  }
  return "Not Equal";
}