Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

Hello, I have the expected result but the console tells me that I must obtain 71.7 for example, but I display 71.7 so I don’t understand.

Your code so far


// User Editable Region

function getAverage(a, b, c, d, e, f, g, h, i, j) {
  return (a + b + c + d + e + f + g + h + i + j) / getAverage.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));
console.log(getAverage(38, 99, 87, 100, 100, 100, 100, 100, 100, 100));

// User Editable Region

// running tests
2. getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]) should return 71.7.
3. getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]) should return 85.4.
4. getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]) should return 92.4.
5. Your getAverage function should return the average score of the test scores.
// tests completed
// console output
71.7
85.4
92.4

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Hi. You need to keep the function parameter named as it was: function getAverage(scores) { }.

The parameter of scores represents all those numbers passed to the function in the console log. You need to work on just “scores” to arrive at the average.

The tips suggest using a loop, and the length property. Reset and have another go and repost your code with 3 backticks before and after if you have further problems.

great thanks I’ll try it :slight_smile:

1 Like