Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

NOTHING IS WORKING! why why why is it not working

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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Can you be more specific about what’s happening? I do see that your {} are mismatched

this is what i have now:

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]);

its still not working

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Can you try talking about how it isn’t working and what you’ve tried to fix it?

What are you talking about, i already told you.

im not going to go through every past attempt

here’s one i just tried:

function getAverage(scores) {
        for (let i = 0; i < scores.length; i++)
} sumTotal = sumTotal * scores[i]
average = sumTotal / scores.length;
return 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]));

will someone please just help me

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

We can’t tell you the solution. I’m asking you to talk about how exactly you’re stuck so I can help you with how you’re stuck. I can’t just tell you how to do this problem. That wouldn’t help you anyways

function getAverage(scores) {

let sum = 0;

let average = 0;

for (let i = 0; i < scores.length; i++){

return(getAverage)

}

}

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]));

Please format your code.

Please try to talk about how you are stuck.

I’m almost positive this doesn’t do what you want it to do. What do you want this to do?

it keeps putting an arrow next to the letters in the middle of the code saying “unexpected token” or “should return a number”

Hi @Sinan

There are some syntax errors in the original code you posted.

The console log shows the line of the first one.
The editor has drawn a red squiggly line under another one.

‘unexpected token’ means you have a syntax error. The arrow says where the error is.

now its saying i is not defined

function getAverage(scores) {

let sumTotal = 0;

let average = 0; {

for (i = 0; i < scores.length; 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]));

ITS STILL not working

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').