Skip to content

Instantly share code, notes, and snippets.

@ndayishimiyeeric
Created May 2, 2022 10:34

Revisions

  1. ndayishimiyeeric created this gist May 2, 2022.
    25 changes: 25 additions & 0 deletions Example 1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    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;
    }
    23 changes: 23 additions & 0 deletions Example 2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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