For loops

for (const number of numbers) { /// what is "const number of numbers" perform?
total = operation(total, number);
}

Hi there,

Is this example in a course? If so, could you link it? :slight_smile:

But in general, the for…of loop is used to iterate over the values in an iterable object.

So, say for instance you have:

const num = [1, 2, 3, 4, 5];

for(const nums of num) {
  console.log(num);
};

The output of this for…of loop would log:

1
2
3
4
5
1 Like

yeah thank you for that

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.