JSFiddle - React, Tailwind, and code Playground

HTML

<p class="favoritesyellow">first</p>
<p class="favoritesyellow">second</p>
<b>third</b>
<p class="favoritesyellow">fourth</p>

CSS

.favoritesred {color: red;}
.favoritesyellow {color: yellow;}

JavaScript

var paragraphs = document.getElementsByTagName('p'),
    i = 0;
for (var p in paragraphs) {
    if (paragraphs.hasOwnProperty(p)) {
        paragraphs[p].classList.add('favoritesred');
        paragraphs[p].classList.remove('favoritesyellow');
    }
}