programming-examples/js/Recursion/Write a JavaScript program to get the integers in range (x, y)..js
2019-11-15 12:59:38 +01:00

15 lines
294 B
JavaScript

var range = function(start_num, end_num)
{
if (end_num - start_num === 2)
{
return [start_num + 1];
}
else
{
var list = range(start_num, end_num - 1);
list.push(end_num - 1);
return list;
}
};
console.log(range(2,9));