CC-07: Array Iteration
with Carmen Salas • 2024/10/15
Arrays
slides review...
for...of syntax when looping through an iterable's values:
for (let item of collection) {
// iterating through values,
// DOES NOT SKIP over undefined/skipped indices
}for...in syntax when looping through an iterable's enumerables:
for (let index in collection) {
// iterating through indices,
// SKIPS over undefined/skipped indices
}Code Challenge
Declare a function named sumInArray that will calculate the sum of all the elements in an array of numbers. You must solve this without using any built-in array methods and iterating through the array.
Declare a function named averageInArray that will calculate the average of the elements in an array of numbers. You must solve this without using any built-in array methods and iterating through the array.
Last updated