Skip to content

Instantly share code, notes, and snippets.

@isaka-lumato
Created August 23, 2021 13:35
Show Gist options
  • Save isaka-lumato/63d46846f685205cd6542fdbc564ea90 to your computer and use it in GitHub Desktop.
Save isaka-lumato/63d46846f685205cd6542fdbc564ea90 to your computer and use it in GitHub Desktop.
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse' 'Lion', 'Dragon'];
// Print all pets
//this code is not dry
console.log(pets[0]);
console.log(pets[1]);
console.log(pets[2]);
console.log(pets[3]);
...
//it should be like this
pets.foreach((pet) => {
console.log(pet);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment