I have been googling for answers and though I do see similar questions posted on Stack, none seem to fit what I'm looking for.
For example with the code below:
HTML
<div class="container">
<h1>Is it morning, afternoon, evening, or night?</h1>
</div>
Javascript
const header = document.getElementByTagName("h1").textContent;
function colorWords()
{
if (header.indexOf("morning"){
header.style.color = "yellow";
});
The end result that I'm trying to achieve is to make the font color different for the words, "morning," "afternoon," and "evening." I was thinking of doing either for loops or using methods ie .indexOf, .search to find those specific words and then using an if-else statement/switch to change the color but I'm not fully sure how to implement this.
Thank you in advance!