Created
August 23, 2021 13:35
-
-
Save isaka-lumato/63d46846f685205cd6542fdbc564ea90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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