Hey, my loop doesnt work i guess. Ive watched the other solution and fixed my problems, but my loop just iterate the first number in this array and than it stops.
Your code so far
// User Editable Region
function getAverage(scores) {
for(let i= 0; i < scores.length;i++){
let sum = 0;
sum = sum + scores[i];
return sum/scores.length;
}
}
console.log(getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]));
console.log(getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]));
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Challenge Information:
Review JavaScript Fundamentals by Building a Gradebook App - Step 1
It gives back whats defined in the return? But he can only give 1 result back?
But everything is happaning just 1 time? But it doesnt fix my problem.
The function tells what to do with each number in the array right? So console log sends the 92 to the function, function is doing what it should do, and than console.log gives next, 88, to the function?
Ive changed the code to:
function getAverage(scores) {
for(let i= 0; i < scores.length;i++){
let sum = 0;
sum = sum + scores[i];