I keep being told my function needs to return a number. I have run this code through other javascript console simulators and it returns the correct number as specified by the. What is the issue with my code?
Your code so far
// User Editable Region
function getAverage(scores) {
let sumTotal = 0;
let average = 0;
for ( i = 0; i < scores.length; i++) {
sumTotal = sumTotal + scores[i];
}
average = sumTotal / scores.length;
return average;
}
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; rv:127.0) Gecko/20100101 Firefox/127.0
Challenge Information:
Review JavaScript Fundamentals by Building a Gradebook App - Step 1
Yeah, I’ve tried to correct that and it still didn’t work. Also, I just went ahead to the next step and tried copying in the answer there, and it still said the code didn’t work. I think something has gone wrong with the JS console on the website.
When I reload the page, this message appears in the console:
What is your code when you fix your bug with i? I can’t see what’s happening if you don’t share your fixed code. The Step works correctly when write I correct code.
Yeah, there was an error with the webpage itself. The cache had some sort of an error and the JS console engine was not loading properly. I cleared the cache and re-logged in and the problem was resolved.