From the course: JavaScript: Best Practices for Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Declare variables

Solution: Declare variables - JavaScript Tutorial

From the course: JavaScript: Best Practices for Data

Start my 1-month free trial

Solution: Declare variables

(upbeat music) - [Instructor] I hope you had fun working with that code. So let's give this a go. I have my code already running using Live Server and over in the browser I can see I have that day logged, like I'd expect. Now depending on where you are, you might see a different local format here. So for instance I'm in the U.S. and I have my month first and then the day, but you might see those two flipped. Or you might see another format depending on what is prevalent where you are. So back in my code, first thing I notice, is that I have a var down here and I don't want vars. So I'm going to go over to my eslintrc and I'll start by adding that no var rule, with a value of error. And that var got flagged, this is a function, so it makes sense to make that a constant and so I'll use const. Change that and now there's no longer an error thrown. Now I'm not using constants throughout but I'd like to be using constants…

Contents