<div id="box" class="active"></div>
const element = document.querySelector("#box");
// Check if hasclass
// Result is a boolean
element.classList.contains("active");
true
const apps = ["phone", "calculator", "clock"];
apps.at(-1);
"clock"
<div id="box"></div>
const element = document.querySelector("#box");
element.classList.add("active", "highlighted");
<div id="box" class="active highlighted"></div>
const text = "codetogo saved me tons of time";
text.replace(/ /g, "-");
codetogo-saved-me-tons-of-time
const people = ["Sam", "Alex", "Charlie"];
people.forEach(person => {
console.log(person);
});
Sam Alex Charlie
<div id="box"></div>
const element = document.querySelector("#box");
element.addEventListener("click", event => {
console.log("Element clicked");
});