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: Compare values - JavaScript Tutorial
From the course: JavaScript: Best Practices for Data
Solution: Compare values
(upbeat music) - [Instructor] So, at the top of my code, I have a cart object, and then I have all of this logical code with all of these comparisons starting on line 11. And looking at this line by line, basically this section is checking the number of items in the cart using some other factors to calculate the shipping, or whether shipping needs to be determined later, and then down here there's this contact property we're setting a value for, and that I just thought of as if there's some complications going on with this order, then we'll flag it to have someone actually reach out, contact the customer, and resolve some issues, or iron some logistics out. So, I'm going to start with the flow control up here. Save that nice, gnarly ternary for a little bit later, and this is one of those places where I think putting the ESLint rules in place first can be really helpful, 'cause they can point out some of those errors…
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
-
-
-
-
-
-
-
(Locked)
Use triple-character equality operators2m 56s
-
(Locked)
Don't use Yoda conditions1m 52s
-
(Locked)
Compare appropriately for the data type2m 2s
-
(Locked)
Use ternary statements judiciously3m 23s
-
(Locked)
Add parentheses to clarify logic2m 3s
-
(Locked)
Challenge: Compare values53s
-
(Locked)
Solution: Compare values9m 29s
-
(Locked)
-