2.3 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244d3 Comparison with the Strict Inequality Operator 1 与严格不等式算子的比较

Description

严格不等式运算符( !== )与严格相等运算符的逻辑相反。它意味着“严格不等于”并返回false ,其中严格相等将返回true 反之亦然 。严格的不等式不会转换数据类型。 例子
3== 3 //假
3=='3'//是的
4== 3 //是的

Instructions

strict inequality operator添加到if语句,以便当val不严格等于17函数将返回“Not Equal”

Tests

tests:
  - text: <code>testStrictNotEqual(17)</code>应返回“Equal”
    testString: 'assert(testStrictNotEqual(17) === "Equal", "<code>testStrictNotEqual(17)</code> should return "Equal"");'
  - text: <code>testStrictNotEqual(&quot;17&quot;)</code>应返回“Not Equal”
    testString: 'assert(testStrictNotEqual("17") === "Not Equal", "<code>testStrictNotEqual("17")</code> should return "Not Equal"");'
  - text: <code>testStrictNotEqual(12)</code>应该返回“Not Equal”
    testString: 'assert(testStrictNotEqual(12) === "Not Equal", "<code>testStrictNotEqual(12)</code> should return "Not Equal"");'
  - text: <code>testStrictNotEqual(&quot;bob&quot;)</code>应返回“Not Equal”
    testString: 'assert(testStrictNotEqual("bob") === "Not Equal", "<code>testStrictNotEqual("bob")</code> should return "Not Equal"");'
  - text: 你应该使用<code>!==</code>运算符
    testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, "You should use the <code>!==</code> operator");'

Challenge Seed

// Setup
function testStrictNotEqual(val) {
  // Only Change Code Below this Line

  if (val) {

  // Only Change Code Above this Line

    return "Not Equal";
  }
  return "Equal";
}

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

Solution

// solution required