课程: JavaScript Essential Training

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Solution: Create a content factory

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…

内容