I have gotten the code to work without the return method, but I can’t get a pass due to not using a return method.
How do I use the return method I don’t understand what they’re asking me to do
Your code so far
// User Editable Region
let average = 0;
let sum = 0;
function getAverage(scores) {
for (let i = 0; i < scores.length; i++){
sum += scores[i]
return getAverage();
}
average = sum / scores.length;
sum = 0;
}
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
Challenge Information:
Review JavaScript Fundamentals by Building a Gradebook App - Step 1
when I would submit my code to kind of test it when it wasnt done on the “check the code” section i’d get a message saying i need to return getAverage()
“Your getAverage function should return a number”, that’s what confused me sorry, I took it as needing to call “return getAverage()” in order to do the code. It’s early in the morning I haven’t fully woken up yet