JSFiddle - React, Tailwind, and code Playground

HTML

<div id="first">mares eat oats</div>

<h1 id="second">
and does eat oats
</h1>

<p id="third">and little lambs eat ivy</p>
<p id="fourth">Mirthipan Karunakaran</p>

CSS

#first {
    text-align: center;
}
#second {
    color: green;
    text-align: left;
}
#third {
    color: orange;
    text-align: right;
}
#fourth {
    color: white;
    background-color: black;
}

JavaScript

function updatePage() {

    var name = document.getElementById("fourth");

    if (name.style.backgroundColor == "black") {
        name.style.backgroundColor = "pink";
        name.style.color = "black";
    } else {
        name.style.backgroundColor = "black";
        name.style.color = "pink";
    }

}

function startUpdate() {
    updatePage();
    window.setInterval(updatePage, 2 * 1000);
}

startUpdate();