Last active
May 8, 2023 15:27
-
-
Save JuniorGarciaRodriguez/f10a15fdb581d5ace497038e047b1634 to your computer and use it in GitHub Desktop.
Is it DRY? m2w3d1
This file contains hidden or 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 | |
| console.log(pets[0]); | |
| console.log(pets[1]); | |
| console.log(pets[2]); | |
| console.log(pets[3]); | |
| ... |
This file contains hidden or 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 greet = (message, name) => { | |
| console.log(`${message}, ${name}!`) | |
| } | |
| greet('Hello', 'John'); | |
| greet('Hola', 'Antonio'); | |
| greet('Ciao', 'Luigi') |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example 1 isn't DRY. It's repeating a
console.logcall for every element of the array instead of using a loopExample 2 is DRY