freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.chinese.md

2.9 KiB

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244d5 Comparison with the Greater Than Or Equal To Operator 1 与大于或等于运算符的比较

Description

greater than or equal to运算符( >= )比较两个数字的值。如果左边的数字大于或等于右边的数字,则返回true 。否则,它返回false 。与等于运算符一样, greater than or equal to运算符将在比较时转换数据类型。 例子
6> = 6 //是的
7> ='3'//是的
2> = 3 //假
'7'> = 9 //假

Instructions

greater than or equal to运算符添加到指示的行,以便返回语句有意义。

Tests

tests:
  - text: <code>testGreaterOrEqual(0)</code>应返回“小于10”
    testString: 'assert(testGreaterOrEqual(0) === "Less than 10", "<code>testGreaterOrEqual(0)</code> should return "Less than 10"");'
  - text: <code>testGreaterOrEqual(9)</code>应返回“小于10”
    testString: 'assert(testGreaterOrEqual(9) === "Less than 10", "<code>testGreaterOrEqual(9)</code> should return "Less than 10"");'
  - text: <code>testGreaterOrEqual(10)</code>应返回“10或Over”
    testString: 'assert(testGreaterOrEqual(10) === "10 or Over", "<code>testGreaterOrEqual(10)</code> should return "10 or Over"");'
  - text: <code>testGreaterOrEqual(11)</code>应返回“10或Over”
    testString: 'assert(testGreaterOrEqual(11) === "10 or Over", "<code>testGreaterOrEqual(11)</code> should return "10 or Over"");'
  - text: <code>testGreaterOrEqual(19)</code>应返回“10或Over”
    testString: 'assert(testGreaterOrEqual(19) === "10 or Over", "<code>testGreaterOrEqual(19)</code> should return "10 or Over"");'
  - text: <code>testGreaterOrEqual(100)</code>应该返回“20或Over”
    testString: 'assert(testGreaterOrEqual(100) === "20 or Over", "<code>testGreaterOrEqual(100)</code> should return "20 or Over"");'
  - text: <code>testGreaterOrEqual(21)</code>应返回“20或Over”
    testString: 'assert(testGreaterOrEqual(21) === "20 or Over", "<code>testGreaterOrEqual(21)</code> should return "20 or Over"");'
  - text: 您应该使用<code>&gt;=</code>运算符至少两次
    testString: 'assert(code.match(/val\s*>=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&gt;=</code> operator at least twice");'

Challenge Seed

function testGreaterOrEqual(val) {
  if (val) {  // Change this line
    return "20 or Over";
  }

  if (val) {  // Change this line
    return "10 or Over";
  }

  return "Less than 10";
}

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

Solution

// solution required