JSFiddle - React, Tailwind, and code Playground

by Maria

HTML

<article>
    <header>
        <h1>Top ten reasons to take a course at George Brown!</h1>
        <span class="author">Maria | </span><span class="date">March 20th</span>
    </header>
    <ol id = "reasons">
        <li>It's fun!</li>
        <li>You'll learn a lot</li>
        <li class="best">Advance your career</li>
    </ol>
</article>

JavaScript

var topList = document.getElementById("reasons");

for (var el = topList.firstElementChild; el; el = el.nextElementSibling) {
    if(el.classList.contains("best")) {
        alert("The best reason to take a course is: " + el.textContent);
}
}