18 lines
305 B
JavaScript
18 lines
305 B
JavaScript
|
function range(start, end, step=1) {
|
||
|
let result = [];
|
||
|
for (let i = start; i <= end; i += step) {
|
||
|
result.push(i);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function sum(array) {
|
||
|
let result = 0;
|
||
|
for (let i = 0; i < array.length; i++) {
|
||
|
result += array[i];
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
exports.range = range;
|
||
|
exports.sum = sum;
|