var array = [];

function range(arr, arr1) {
    var smallest = Math.min(arr);
    var biggest = Math.max(arr1);
    for (var i = smallest; i <= biggest; i++) {
        array.push(i);
    }
}

function sum() {
    var total = 0;
    for (var i = 0; i < array.length; i++) {
        total = total + array[i];
    }
    return total;
}
console.log(sum(range(1, 10)));
55