function range(start, end, step) {
    var arr = [];
    var mystep = arguments.length == 3 ? step : 1;
    var val = start;
    while (true) {
        arr.push(val);
        val += mystep;
        if (start < end && val > end || start > end && val < end)
            break;
    }
    return arr;
}

function sum(arr) {
    var res = 0;
    console.log(arr);
    for (var i = 0; i < arr.length; ++i)
        res += arr[i];
    return res;
}

function range(start, end, step = start < end ? 1 : -1) {
    arr = [];
    if (step > 0) {
        for (n = start; n <= end; n += step) {
            arr.push(n);
        }
    } else if (step < 0) {
        for (n = start; n >= end; n += step) {
            arr.push(n);
            }
    }
    return arr;
}

function sum(arr) {
    s = 0;
    for (let num of arr) {
        s += num;
    }
    return s;
}

Add Chapter 04, exercise 1
Add Chapter 04, exercise 1
