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: Type cast - JavaScript Tutorial
From the course: JavaScript: Best Practices for Data
Challenge: Type cast
(upbeat music) - [Instructor] Ready to type cast some values using best practices? It's time for a challenge. My code starts with some string data from a weather service, converts a Celsius temperature to Fahrenheit, and then takes a first step in putting that data in the view by console.logging it. Your task is to type cast data when necessary and then update existing type casting as necessary to use best practices. I've highlighted here on lines 11 and 16 where type casting needs to happen in the statements that follow those comments. You'll have to decide on the best approach to doing that. In addition, the code works with Booleans a few times, and you should make sure that best practices are being implemented in all of these statements. Add rules as appropriate to dot ESLint RC to check for issues, as well as fixing those issues in the app.js file. This exercise should take you about 10 minutes. When you're done…
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)
Type cast strings with the String wrapper2m 58s
-
(Locked)
Type cast numbers with the Number wrapper1m 40s
-
(Locked)
Type cast Booleans using double negation2m 14s
-
(Locked)
Rely on implicit Boolean values in conditionals1m 45s
-
(Locked)
Challenge: Type cast1m 7s
-
(Locked)
Solution: Type cast2m 39s
-
(Locked)
-
-