function range in JavaScript code example
Example 1: range javascript
[...Array(5).keys()];
=> [0, 1, 2, 3, 4]
Example 2: range in javascript
function range(start, end, interval = 0) {
let arr = [];
interval = interval > 0 ? interval-1 : 0
for (let i = start; i < end; i++) {
arr.push(i)
i+=interval;
}
return arr
}
// example range(0 , 100 , 5)