Skip to content

Instantly share code, notes, and snippets.

@Graciano1997
Last active July 25, 2023 16:40
Show Gist options
  • Save Graciano1997/21fe643c1da0feb99831b04105b2f65f to your computer and use it in GitHub Desktop.
Save Graciano1997/21fe643c1da0feb99831b04105b2f65f to your computer and use it in GitHub Desktop.
.greetings {
font-family: Arial, sans-serif;
font-size: 1.5rem;
}
.greetings.english {
background-color: #000;
color: #FFF;
}
.greetings.spanish {
background-color: #FFF;
color: #000;
}
const greet = (message, name) => {
console.log(`${message}, ${name}!`)
}
greet('Hello', 'John');
greet('Hola', 'Antonio');
greet('Ciao', 'Luigi')
.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;
}
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]);
@Graciano1997
Copy link
Author

Graciano1997 commented Jul 25, 2023

the pet.css and pet.js are not DRY:

pet.css a possible DRY version :

.pet {
font-family: "Times New Roman", Times, serif;
font-size: 1rem;
}

.cat { color: #FFF; }
.dog {color: #000;}
.dragon {color: #009933;}

pet.js a possible DRY version:

const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse', 'Lion', 'Dragon'];
// Print all pets

pets.forEach(pet=>console.log(pet));

@Graciano1997
Copy link
Author

The greet.css and greet.css are DRY.

Because it does not repeat again the same code logic, and it refactors the existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment