Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js range array

function range(start, end) {
    if(start === end) return [start];
    return [start, ...range(start + 1, end)];
}

range(1, 4) //Output: Array(4) [ 1, 2, 3, 4 ]
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #js #range #array
ADD COMMENT
Topic
Name
1+6 =