Cache the element instead of looking up the element every second:
const clockElement = document.getElementById("clock");
Cache it once.
Example:
const clockElement = document.getElementById("clock");
function getTheDate() {
if (!clockElement) return;
...
clockElement.textContent = ...
}
Cache the element instead of looking up the element every second:
Cache it once.
Example: