Skip to content

Instantly share code, notes, and snippets.

@ndayishimiyeeric
Created May 2, 2022 10:34
Show Gist options
  • Save ndayishimiyeeric/e47232acdf6fddf97ebb10f2c62b47ab to your computer and use it in GitHub Desktop.
Save ndayishimiyeeric/e47232acdf6fddf97ebb10f2c62b47ab to your computer and use it in GitHub Desktop.
Microverse Is It DRY Exercise
The Code in the example 1 is not DRY Because there repetition.
below there is the atleast DRY Code of javascript.
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse', 'Lion', 'Dragon'];
//Print all pets
pets.forEach((pet) => console.log(pet));
below there is it atleast dry code of css.
.cat,
.dog,
.dragon {
font-family: "Times New Roman", Times, serif;
font-size: 1rem;
color: #FFF;
}
.dog {
color: #000;
}
.dragon {
color: #009933;
}
const greet = (message, name) => {
console.log(`${message}, ${name}!`)
}
greet('Hello', 'John');
greet('Hola', 'Antonio');
greet('Ciao', 'Luigi')
.greetings {
font-family: Arial, sans-serif;
font-size: 1.5rem;
}
.greetings.english {
background-color: #000;
color: #FFF;
}
.greetings.spanish {
background-color: #FFF;
color: #000;
}
The code in the example 2 is DRY there is no repetition of line of codes both is JS and CSS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment