curriculum/challenges/english/blocks/review-js-fundamentals-by-building-a-gradebook-app/662693f82c91a66be46c881b.md
A teacher has finished grading their students' tests and needs your help to calculate the average score for the class.
Complete the getAverage function which takes in an array of test scores and returns the average score.
The average is calculated by adding up all the scores and dividing by the total number of scores.
average = sum of all scores / total number of scores
A couple of function calls have been provided for you so you can test out your code.
Tips
scores array and add up all the scores.length property to get the total number of scores.Your getAverage function should return a number.
assert.strictEqual(typeof getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]), 'number');
getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]) should return 71.7.
assert.strictEqual(getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]), 71.7);
getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]) should return 85.4.
assert.strictEqual(getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]), 85.4);
getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]) should return 92.4.
assert.strictEqual(getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]), 92.4);
Your getAverage function should return the average score of the test scores.
assert.strictEqual(getAverage([52, 56, 60, 65, 70, 75, 80, 85, 90, 95]), 72.8);
assert.strictEqual(getAverage([45, 50, 55, 60, 65, 70, 75, 80, 85, 90]), 67.5);
assert.strictEqual(getAverage([38, 42, 46, 50, 54, 58, 62, 66, 70, 74]), 56);
--fcc-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]));
--fcc-editable-region--