You're writing longer, more complicated code. For example, instead of writing
checked: localStorage.getItem("theme") === "dark" ? true : false,
You can write:
checked: localStorage.getItem("theme") === "dark",
because localStorage.getItem("theme") === "dark" is a boolean and its value will be true or false.
localStorage.getItem("theme") === "dark"
Also, instead of writing
document.getElementsByTagName("HTML")[0]
You can write
document.querySelector("html")
and it will do the same thing.
There's nothing wrong with your code, but I'm just telling you how to make it more efficient
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You're writing longer, more complicated code. For example, instead of writing
You can write:
because
localStorage.getItem("theme") === "dark"
is a boolean and its value will be true or false.Also, instead of writing
You can write
and it will do the same thing.
There's nothing wrong with your code, but I'm just telling you how to make it more efficient