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 - JavaScript Tutorial
From the course: JavaScript: Best Practices for Data
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Prefer const, then let5m 7s
-
(Locked)
Use individual statements to create variables1m 41s
-
(Locked)
Create descriptive variable names3m
-
(Locked)
Standardize acronym case2m 22s
-
(Locked)
Remove unused variables1m 18s
-
(Locked)
Challenge: Declare variables45s
-
(Locked)
Solution: Declare variables5m 38s
-
-
-
-
-