Please format your code.
Please try to talk about how you are stuck.
You did not declare i.
Also, this isn’t correct syntax for a for loop.
Please format your code.
Please try to talk about how you are stuck.
You did not declare i.
Also, this isn’t correct syntax for a for loop.
k…first it says average is not a function, when i got i cleared up, then it says getAverage is not a function…then it says some other edits are wrong, then when i bring them back it says theyre wrong???
“TypeError: getAverage is not a function”
average is not a function
why is no one helping
can someone please please help
fix these:
average = sumTotal + scores[i]; inside the for loop.; in the end of the for loop declaration and replace what should be in there instead.edit:
4. i forgot to mention, you forgot to close the getAverage function.
I hope this hints are clear and enough.
thank you!
here’s an edit of an edit of an edit:
function getAverage(); {
for(sumTotal = sumTotal + scores[i])
(average = sumTotal / 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]));
stil not working i must have a problem with my computer
i even tried including the old text in the for loop together with the other text
i think im starting to get it:
function getAverage(scores) {
let sumTotal = 0;
let average = 0;
for(average = sumTotal + scores[i]); {
console.log(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]));
Your original code contains just a few errors.
Use the advice you were given to correct the syntax errors in the above code block.
STILL NOT WORKING 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)); EDIT: I even tried without any semi colons
Functions require opening and closing curly braces.
for loops require opening and closing curly braces.
Also, the for loop is missing a round brace after the iterator.
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));
oh by curly brace do you mean this" [ ]" that didnt work either EDIT: sorry i have trouble with semantics due to being on the spectrum
The first part of the function is nearly correct, just remove the semi colon.
The below code is not the way to declare a function.
Here is an example from the Pyramid Generator practice project.
Curly braces {}
function test () { getAverageScores
}
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)); im dying inside i gotta sleep but first i gotta get this done
ok i put scores in parenthese now what
You added the example code from the Pyramid Generator to the Gradebook App code.
Try making the two edits suggested below, do not change anything else.
Also, add a closing curly } brace after the return statement to close the function body.