programming-examples/js/Array/Write a JavaScript function to generate an array of specified length, filled with integer numbers, increase by one from starting position..js

14 lines
305 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function array_range(start, len)
{
var arr = new Array(len);
for (var i = 0; i < len; i++, start++)
{
arr[i] = start;
}
return arr;
}
console.log(array_range(1, 4));
console.log(array_range(-6, 4));