Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

Hi there

I need some help please? anyone got any ideas

I think I need a for loop?

Thanks alot
Iskren

Your code so far


// User Editable Region

const scores1 = 92+88+12+77+57+100+67+38+97+89;
console.log(scores1)

const scores2=45+87+98+100+86+94+67+88+94+95;
console.log(scores2)



function getAverage(scores){
  return scores1/total1;
}

function getAverage2(scores){
  return scores2/total2;
}


const getAverage1 =[92, 88, 12, 77, 57, 100, 67, 38, 97, 89]
const getAverage2 =[45, 87, 98, 100, 86, 94, 67, 88, 94, 95]

let total1 = getAverage1.length
console.log(total1);
let total2 = getAverage2.length;
console.log(total2);

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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

you are being asked to complete the getAverage function which takes in an array of test scores and returns the average score.
use this to find the average.
average = sum of all scores / total number of scores

I think I need a for loop, is that correct?

yes you need a for loop for this

you need the loop to iterate over the scores, when you’re done with the loop the next thing is to find the average of the scores.