From the course: JavaScript Code Challenges: Creating Web Apps

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Final touches

Final touches

- [Instructor] All right, our app is working, but it can definitely benefit from some final touches. So let's have a look and refactor it to make it look even better. Okay, let's see. What can I improve? Well, the first thing I noticed is that my theme toggle on line 20, I actually forgot to declare it upstairs, and that's a bad practice. It's still working, though, and that's because browsers automatically creates a global variable with the name of the ID. And since I have the same ID name here, it will work, but it's not a good practice. So, let's go ahead and declare it on top of our file to make sure it's always working, and we won't have to rely on default behavior. So, this is pretty good. There is one thing that's bothered me a little bit. And that's it, I want to have this separately. So I'm going to say here instead, function, handleThemeToggle. And in here, I'm just going to have this line of codes. And instead of having an arrow function here, I'm going to go with…

Contents