Tell us what’s happening:
Hi, I am very lost on where to start. Please help.
Your code so far
// 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
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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
soryaek
February 19, 2025, 10:14pm
2
@ghost_bentley
You can think of this as a math problem. To calculate the average score, add all the numbers in the array and divide the sum by the length of the array.
Hope this helps you get started!
That was helpful, thanks. But, I am still a bit confused as to why my code is not passing still.
My hint says:
Your getAverage
function should return a number.
My console says:
And this is my code:
function getAverage(scores) {
let sum = 0;
console.log(scores);
for(let i=0;i < scores.length;i++){
sum= sum + scores[i];
}
console.log(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]));
console.log(getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]));
Any help will be much appreciated. Thank you.
ILM
February 20, 2025, 4:54pm
4
do you remember how you return a value from a function? it is a different thing than printing to the console
1 Like
Thank you so much!!! That was all I needed!!
Where did you start? I understand the task mathematically, but am not quite sure how to put it in JS.
Hi. Can you please open a new topic for your issue with the step. I’ll close this thread.
1 Like