# Review JavaScript Fundamentals by Building a Gradebook App - Step 1

### Tell us what’s happening:

Am confused, how can l complete the getAverage function which takes in an array of test scores and returns the average score?

``````
// User Editable Region

function getAverage(scores) {

}

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

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0`

### Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

what have you tried so far? the instructions give you various tips from which you can start

yeah, the tips are just confusing me

Do you know how to manually calculate the average of a set of numbers?

yes l do, sum the scores then divide by the total number of scores

let’s start from summing the scores, you have an array, you need to sum all the elements in the array to each other.
How could you do that?

am still confused, do l just go on and sum up the array of the first scores in the getAverage function body?

You use the `scores` parameter to access whatever array the function is called with

still not getting, can l have like an illustration of what you are trying to mean?

A function is created with parameters, in this case `scores`, the value of the parameter is determined when the function is called, so

here the value of `scores` is `[92, 88, 12, 77, 57, 100, 67, 38, 97, 89]`

Am defeated, l have tried several times but l’ve failed. l need help with everything or step

show your code, it’s the best way to get help

### Tell us what’s happening:

How can l complete the getAverage function which takes in an array of test scores and returns the average score?

``````
// User Editable Region

function getAverage(scores) {
let sum = 0;
for (let i = 0; i < scores.length; i++) {sum += scores[i];}
}

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

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0`

### Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

l have posted a new chat to show the code so far

what issue are you having? it looks like you are summing the values inside `scores` correctly

now you need to finish calculating the average and write the return statement

Can you illustrate how am to calculate the average and write the return statement?

You got the `sum`.

Now return `sum` divided by (numbers of elements in `scores` array).

How to count numbers of elements in `scores` array?

you said yourself that the average is the sum divided the number of items. You can easily get the number of items, it is a property of arrays

thanks guys, it has passed, l really appreciate your help