main.js 263 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
function promedio(array) {
    var promedio = 0;
    var sum = 0;
    for (let i = 0; i < array.length; i++) {
        sum += array[i];
    }
    promedio = sum / array.length;
    return promedio;
}
var vector = [9, 5, 7, 8, 1, 3];
console.log(promedio(vector));