Answers for "function range() as range js"

13

range javascript

[...Array(5).keys()];
 => [0, 1, 2, 3, 4]
Posted by: Guest on May-20-2020
1

function range() as range js

function range(start, end) {
	/* generate a range : [start, start+1, ..., end-1, end] */
	var len = end - start + 1;
	var a = new Array(len);
	for (let i = 0; i < len; i++) a[i] = start + i;
	return a;
}
Posted by: Guest on March-09-2020
0

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)
Posted by: Guest on May-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language