Files
freeCodeCamp/curriculum/challenges/russian/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-inequality-operator.russian.md

2.4 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
56533eb9ac21ba0edf2244d3 Comparison with the Strict Inequality Operator 1 https://scrimba.com/c/cKekkUy 16791 Сравнение с оператором строгого неравенства

Description

Оператор строгого неравенства ( !== ) является логической противоположностью оператора строгого равенства. Это означает «строго не равно» и возвращает false когда строгое равенство вернет true и наоборот . Строгое неравенство не будет преобразовывать типы данных. Примеры
3! == 3 // false
3! == '3' // true
4! == 3 // true

Instructions

Добавьте strict inequality operator if чтобы функция вернула «Не равно», когда val строго не равно 17

Tests

tests:
  - text: <code>testStrictNotEqual(17)</code> should return "Equal"
    testString: assert(testStrictNotEqual(17) === "Equal");
  - text: <code>testStrictNotEqual("17")</code> should return "Not Equal"
    testString: assert(testStrictNotEqual("17") === "Not Equal");
  - text: <code>testStrictNotEqual(12)</code> should return "Not Equal"
    testString: assert(testStrictNotEqual(12) === "Not Equal");
  - text: <code>testStrictNotEqual("bob")</code> should return "Not Equal"
    testString: assert(testStrictNotEqual("bob") === "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 testStrictNotEqual(val) {
  if (val) { // Change this line
    return "Not Equal";
  }
  return "Equal";
}

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

Solution

function testStrictNotEqual(val) {
  if (val !== 17) {
    return "Not Equal";
  }
  return "Equal";
}