function setColour(colour) { if ((colour === "black" || colour === "white") || ((colour !== "blue") && (colour !== "green") && (colour !== "red") && (colour !== "yellow"))) { colour = "red"; } localStorage.setItem("colour",colour); var root = document.querySelector(":root"); var rootstyle = getComputedStyle(root); const colourValue = rootstyle.getPropertyValue("--" + colour); root.style.setProperty("--colour",colourValue); }