From the course: JavaScript: Best Practices for Functions and Classes

Unlock the full course today

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

Challenge: Destructure

Challenge: Destructure - JavaScript Tutorial

From the course: JavaScript: Best Practices for Functions and Classes

Start my 1-month free trial

Challenge: Destructure

(bright upbeat music) - [Instructor] Ready to implement destructuring to improve your code? It's time for a challenge. My start code includes an object full of weather data, of the type that might be returned by a call to a weather API. Further down, it also includes an array that stores abbreviations for degrees Celsius and degrees Fahrenheit. My code also breaks out the values I want from the object and from the array, by assigning them to their own variables. Your task is to replace this variable reassignment with object destructuring for the weather data, and with array destructuring for the abbreviations. Be sure to implement an ESLint rule to flag any instances where you need to swap out variables for destructuring. Destructuring syntax can work a number of different ways, depending on the use case. This code is slightly different than what you saw in the videos in this chapter. So, if destructuring isn't…

Contents