mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-01 00:03:50 -05:00
2.0 KiB
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";
}