2.5 KiB
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> "غير مساوي"
testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
- text: <code>testStrict(7)</code> إرجاع "Equal"
testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
- text: <code>testStrict("7")</code> إرجاع "غير مساوي"
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