@isprutfromua
Posted
Hi there. You did a good job 😎
keep improving your programming skills🛠️
your solution looks great, however, if you want to improve it, you can follow these recommendation:
✅ don't use onclick . There may be specific use cases for it, but if you are not 100% sure you have that use case, then you do not and should not use inline events.
btn.onclick = function darkMode()
✅ avoid classes expressions. It will be better if you check the mode by value in the local storage
document.body.classList.contains('light-mode')
✅ don't repeat yourself . The code is very similar, you can simplify the logic with ternary operators
images.src = './images/icon-moon.svg';
bgImg.src ='./images/bg-desktop-light.jpg';
} else {
images.src = './images/icon-sun.svg';
bgImg.src ='./images/bg-desktop-dark.jpg';
I hope my feedback will be helpful. You can mark it as useful if so 👍 it is not difficult for you, but I understand that my efforts have been appreciated
Good luck and fun coding 🤝⌨️
Marked as helpful