Why doesn’t my JS update my data-theme back?

I want to have a button inside my navbar (ul li) that can toggle between theme=light and theme=dark. However, only activating dark mode works. Code: I created a button <li><a href=”#” onclick=”darkMode()”><i class=”fas fa-moon”></i></a></li>, with a JS function and my css looks like this: Answer 1. You start the function by setting the isOn to false. so Boolean(isOn) === false alwaeys return true. you should init the isOn variable outside the function 2 Why you convert the isOn to boolean? it’s already boolean type.. 3 You not really need else if.. if it is not false it is true.. 4.