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

2.9 KiB

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244d6 Comparison with the Less Than Operator 1 مقارنة مع أقل من المشغل

Description

يقارن أقل من المشغل ( < ) قيم رقمين. إذا كان الرقم إلى اليسار أقل من الرقم إلى اليمين ، فسيعود إلى الحالة true . خلاف ذلك ، فإنها ترجع false . مثل المشغل المساواة ، أقل من المشغل يحول أنواع البيانات أثناء مقارنة. أمثلة
2 <5 / صحيح
"3" <7 // صحيح
5 <5 // خاطئة
3 <2 // false
"8" <4 // كاذبة

Instructions

إضافة less than المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية.

Tests

tests:
  - text: يجب أن ترجع <code>testLessThan(0)</code> &quot;تحت 25&quot;
    testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
  - text: يجب أن ترجع <code>testLessThan(24)</code> &quot;تحت 25&quot;
    testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
  - text: يجب أن ترجع <code>testLessThan(25)</code> &quot;تحت 55&quot;
    testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
  - text: يجب أن ترجع <code>testLessThan(54)</code> &quot;تحت 55&quot;
    testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
  - text: <code>testLessThan(55)</code> إرجاع &quot;55 أو أكثر&quot;
    testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
  - text: يجب أن ترجع <code>testLessThan(99)</code> &quot;55 أو أكثر&quot;
    testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
  - text: يجب عليك استخدام <code>&lt;</code> المشغل مرتين على الأقل
    testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&lt;</code> operator at least twice");'

Challenge Seed

function testLessThan(val) {
  if (val) {  // Change this line
    return "Under 25";
  }

  if (val) {  // Change this line
    return "Under 55";
  }

  return "55 or Over";
}

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

Solution

// solution required