Skip to content

Instantly share code, notes, and snippets.

@appoll
Created May 28, 2021 17:35
Show Gist options
  • Save appoll/ab25190977913bf6eb5017a156899da0 to your computer and use it in GitHub Desktop.
Save appoll/ab25190977913bf6eb5017a156899da0 to your computer and use it in GitHub Desktop.
ages = [12, 16, 24, 98, 64, 24, 98, 64, 24, 98, 64]
// Print all the ages in your array :)
// We use the for loop
for (let i = 0; i < ages.length; i = i + 1){
let currentAge = ages[i];
console.log("Position is: " + i);
console.log("Value is: " + currentAge);
}
// E0. Print all the ages in the array in reverse order;
for (let i = 0; i < ages.length; i = i + 1){
}
// E1. Print all positions of all ages greater than 18;
// E2. Iterate through the array and calculate the sum of its values;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment