From the course: JavaScript Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Solution: Create a content factory - JavaScript Tutorial
From the course: JavaScript Essential Training
Solution: Create a content factory
(upbeat music) - [Instructor] There are several ways you can solve this challenge. I'll walk you through the one I think is the most straightforward. It all happens inside the create backpack markup function. This will be our content factory. What we need to do is grab the backpack object array and then iterate through each of the items and generate HTML for the data within each of the items and then somehow return that. And if we look inside create backpack markup right now, you'll notice we're sort of partway there already. We have a constant called content that can contains HTML for our backpack objects, but currently it's just calling one of the backpacks. Then content is returned to our testing function. So I need to change the contents within content to contain all the information for both of the backpacks. And I can do that using the map method. So at the very top here, I'll start out by creating a couple of new…
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
-
-
-
-
-
-
-
-
-
-
The real-world function2m 49s
-
(Locked)
Functions and methods6m 23s
-
(Locked)
A standard function3m 53s
-
(Locked)
The arrow function4m 49s
-
(Locked)
Arrow functions and "this"4m 20s
-
(Locked)
Practice: Build a function1m 31s
-
(Locked)
Pass data to a function with parameters4m 56s
-
(Locked)
Return values from a function7m 1s
-
(Locked)
Practice: Pass values between functions2m 33s
-
(Locked)
Callbacks5m 29s
-
(Locked)
Conditional if...else statement5m 52s
-
(Locked)
Logical operators3m 31s
-
(Locked)
Conditional switch statement5m 55s
-
(Locked)
Looping through content5m 19s
-
(Locked)
Using the map() array method4m 52s
-
(Locked)
Challenge intro: Create a content factory2m 36s
-
(Locked)
Solution: Create a content factory5m 21s
-
-
-
-