MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / range

Function range

code/intro.js:1–13  ·  view source on GitHub ↗
(start, end, step)

Source from the content-addressed store, hash-verified

1function range(start, end, step) {
2 if (step == null) step = 1;
3 var array = [];
4
5 if (step > 0) {
6 for (var i = start; i <= end; i += step)
7 array.push(i);
8 } else {
9 for (var i = start; i >= end; i += step)
10 array.push(i);
11 }
12 return array;
13}
14
15function sum(array) {
16 var total = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected