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.
Challenge: Compare values - JavaScript Tutorial
From the course: JavaScript: Best Practices for Data
Challenge: Compare values
(upbeat bouncy music) - [Narrator] Ready to try your hand at writing better comparisons? It's time for a challenge. I've written some code that simulates a shopping cart and performs a few actions based on values in the cart object. Your task is to update the code to make it easier to read and to follow best practices for comparisons. Add rules as appropriate to .ESLint RC, to check for issues, as well as fixing those issues in the app.js file. Note that the code I've written is intentionally convoluted here and there. So if you're not sure what a statement is doing, take a moment, step back, and break it down. This exercise should take you about 15 minutes. When you're done, join me in the next video, and I'll walk you through how I approached it.
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)
-