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));