📜  使用递归创建数字范围 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:04.342000             🧑  作者: Mango

代码示例1
function rangeOfNumbers(startNum, endNum) {
  if (endNum - startNum === 0) {
    return [startNum];
  } else {
    var numbers = rangeOfNumbers(startNum, endNum - 1);
    numbers.push(endNum);
    return numbers;
  }
}