the max value will be 717 .
i starts at 0. Think of i as a counter for the loop.
i increases by 1 on each round of the loop. The loop is going to go through the numbers in the array and add each one to sum.
The SUM might be 717, but we are not adding those values to i. The variable i only goes up by 1 on each cycle of the loop.
for (let i = 0; ; i++) {
This code is the control for the loop. So far it knows to start at 0 and increase by 1 on each round, but it will never stop. It needs to know how many times to repeat.
How many times do we want the loop to iterate?
Blockquote 10 times since there are 10 numbers
honestly i have no idea im just guessing
Exactly, so we could put that into the loop control like this:
for (let i = 0; i < 10; i++) {
So i will go from 0-9. But we can derive this using length as we did before, right?
well i understand how length works i just didnt know if it could be used in place of i < 10 or if i use it someone else in the code. how late are you going to be around becuse I have to leave for a while ill be back in 3.5 hours or tomorrow at 11am pacific time.
Ok but the last piece for now i < can you fill in the length value?
btw which lesson in the previous tutorials teaches an example of calculating the averages inside of a function that has a parameter ?
Not sure, I havenât done this course yet
Ok but the last piece for now i < can you fill in the length value?
â i < .length; â is that it?
what i mean is is that the right code?
The length of what? Where did you get the number 10? You canât just write length by itselfâŚ
So we have:
for (let i = 0; i < 10; i++) {
console.log(i)
}
This will print 0,1,2,3,4,5,6,7,8,9
function getAverage(scores) {
let sum = 0;
for (let i = 0; i < 10; i++) {
sum +=
}
}
You want to add each value in the array scores to sum. Can you finish this line to access the number in position i of scores ?
sum +=
there are 10 scores altogether. what about .lenght(getAverage) or .length(scores)? Again I dont really know I am just guessing. the previous 120 tutorials before this project taught me nothing about calculation an average number inside of a function with items already inside a console.log
Donât guess. Look it up. I even gave you the link:
It doesnât matter. You learned basic tools now you are putting them together to solve a problem.
Every problem is different but the tools are the same.
oh i didnt see that sorry
You want to add each value in the array scores to sum. Can you finish this line to access the number in position i of scores ?
sum +=
heres what i got so far
function getAverage(scores) {
for (let i = 0; i < getAverage.length; i++) {
}
sum +=
no i cant im confused.