- Example 1:
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]);
...
.cat { font-family: "Times New Roman", Times, serif; font-size: 1rem; color: #FFF; }
.dog { font-family: "Times New Roman", Times, serif; font-size: 1rem; color: #000; }
.dragon { font-family: "Times New Roman", Times, serif; font-size: 1rem; color: #009933; }
Answer the question: "Is it DRY?" If it is not DRY, show how you can make it DRY by adding your version of the code. If it is DRY, explain why it is DRY.
-
Example 1 is not DRY.
-
My DRY code for js file:
pets.forEach(item => console.log(item));
- My DRY code for css file:
.font-family-size { font-family: "Times New Roman", Times, serif; font-size: 1rem; }
.cat { color: #FFF; }
.dog { color: #000; }
.dragon { color: #009933; }