freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../basic-javascript/comparison-with-the-strict-...

2.5 KiB

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244d1 Comparison with the Strict Equality Operator 1 مقارنة مع مشغل المساواة الصارمة

Description

المساواة === ( === ) هي نظير مشغل المساواة ( == ). ومع ذلك ، على عكس مشغل المساواة ، الذي يحاول تحويل كلتا القيمتين مقارنة بالنوع الشائع ، فإن مشغل المساواة الصارم لا يقوم بتحويل نوع. إذا كانت القيم التي يتم مقارنتها لها أنواع مختلفة ، فإنها تعتبر غير متساوية ، وسيعود المشغل الصارم للمساواة كاذبة. أمثلة
3 === 3 // true
3 === '3' // false
في المثال الثاني ، 3 هو نوع Number و '3' هو نوع String .

Instructions

استخدم عامل التساوي الصارم في العبارة if بحيث تقوم الدالة بإرجاع "Equal" عندما تكون val تساوي تمامًا 7

Tests

tests:
  - text: يجب أن ترجع <code>testStrict(10)</code> &quot;غير مساوي&quot;
    testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
  - text: <code>testStrict(7)</code> إرجاع &quot;Equal&quot;
    testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
  - text: <code>testStrict(&quot;7&quot;)</code> إرجاع &quot;غير مساوي&quot;
    testString: 'assert(testStrict("7") === "Not Equal", "<code>testStrict("7")</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 testStrict(val) {
  if (val) { // Change this line
    return "Equal";
  }
  return "Not Equal";
}

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

Solution

// solution required