Randell Dawson e9212c61d2 fix(curriculum): Remove unnecessary assert message argument from English challenges JavaScript Algorithms and Data Structures - 01 (#36401)
* fix: rm assert msg basic-javascript

* fix: removed more assert msg args

* fix: fixed verbiage

Co-Authored-By: Parth Parth <34807532+thecodingaviator@users.noreply.github.com>
2019-07-13 08:07:53 +01:00

1.9 KiB

id, title, challengeType, videoUrl
id title challengeType videoUrl
56533eb9ac21ba0edf2244d1 Comparison with the Strict Equality Operator 1 https://scrimba.com/c/cy87atr

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 "Equal" when val is strictly equal to 7

Tests

tests:
  - text: <code>testStrict(10)</code> should return "Not Equal"
    testString: assert(testStrict(10) === "Not Equal");
  - text: <code>testStrict(7)</code> should return "Equal"
    testString: assert(testStrict(7) === "Equal");
  - text: <code>testStrict("7")</code> should return "Not Equal"
    testString: assert(testStrict("7") === "Not Equal");
  - text: You should use the <code>===</code> operator
    testString: assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);

Challenge Seed

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

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

Solution

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