Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ahmed025566/db276c3d1744f1d42b14e2fbbcb9c04d to your computer and use it in GitHub Desktop.

Select an option

Save ahmed025566/db276c3d1744f1d42b14e2fbbcb9c04d to your computer and use it in GitHub Desktop.
Is it DRY ?
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse', 'Lion', 'Dragon'];
// Print all pets
console.log(pets[0]);
console.log(pets[1]);
console.log(pets[2]);
console.log(pets[3]);
....
It is not DRY and here you can see how to make it DRY :
pets.forEach((item) => console.log(item))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment