function darkmode() { const body = document.body; const headerText = document.getElementById("header-text"); const h1Elements = document.getElementsByTagName("h1"); // Select all h1 elements // Check if we're currently in light mode (white or default) if (body.style.backgroundColor === "white" || body.style.backgroundColor === "") { // Switch to dark mode body.style.backgroundColor = "black"; body.style.color = "white"; // Update all h1 elements to white for (let h1 of h1Elements) { h1.style.color = "white"; } // Set header-text color if element exists if (headerText) { headerText.style.color = "#B1C8C6"; } } else { // Switch to light mode body.style.backgroundColor = "white"; body.style.color = "black"; // Update all h1 elements to black for (let h1 of h1Elements) { h1.style.color = "black"; } // Reset header-text color if element exists if (headerText) { headerText.style.color = "black"; } } }