Skip to content

Instantly share code, notes, and snippets.

@appoll
Created November 30, 2022 18:56
Show Gist options
  • Save appoll/5faa849a65bd54651e6786bdfbf3336b to your computer and use it in GitHub Desktop.
Save appoll/5faa849a65bd54651e6786bdfbf3336b to your computer and use it in GitHub Desktop.
// // Add the string "passed" to every element in the array below:
let students = ["Sebastian", "Oliver", "Samuel", "Hugo", "Lily", "Vasilis"]
students.forEach((value, index, array) => {
console.log(value);
array[index] += " passed";
})
console.log(students);
// Add the length of each name to each string element in the array below:
// e.g. "Paul 4" "Sebastian 9"
// // Add 10 % to each price in the folowing array, using foreach and arrow function
// let prices = [10, 20, 30, 40, 50]
// prices.forEach((value, index, array) => {
// console.log(value);
// array[index] += "...";
// })
// console.log(prices);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment