Files
freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md
2022-10-20 09:13:17 -07:00

2.0 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244d1 المقارنات باستخدام المساواة الصارمة 1 https://scrimba.com/c/cy87atr 16790 comparison-with-the-strict-equality-operator

--description--

يكون مشغل المساواة الصارمة (===) نظير مشغل المساواة (==). ومع ذلك، وخلافاً لمشغل المساواة، الذي يحاول تحويل القيمتين إلى نوع مشترك، لا يقوم مشغل المساواة الصارمة (strict equality) بإجراء تحويل من نوع إلى آخر.

وإذا كانت القيم التي تجري مقارنتها ذات أنواع مختلفة، فإنها تعدّ غير متساوية، وسيعيد مشغل المساواة الصارمة القيمة false.

على سبيل المثال

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

في المثال الثاني، تكون 3 من نوع Number ويكون '3' من نوع String.

--instructions--

استخدام مشغل المساواة الصارمة في بيان if حتي تنتج الوظيفة مقطع باسم Equal عندما يكون val مساوية بطريقة صارمة (strictly equal) إلى 7.

--hints--

يجب أن ينتج testStrict(10) مقطع Not Equal

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

يجب أن ينتج testStrict(7) مقطع Equal

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

يجب أن ينتج testStrict("7") مقطع Not Equal

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

يجب عليك استخدام مشغل ===

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";
}