课程: JavaScript: Five Advanced Challenges and Concepts
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Advanced solution: Add nested comments - JavaScript教程
课程: JavaScript: Five Advanced Challenges and Concepts
Advanced solution: Add nested comments
(bright upbeat music begins) - [Instructor] This challenge is similar to the second example I provided in this chapter, where we took the restructured array and then we turned it into actual output, using a recursive function. So that's what we'll do in this challenge. Looking at the answer code, you'll see I've already built out the function to turn the flat array into a multidimensional array, because you already solved that in the previous challenge. What you need to know is, in the test code here, we first call restructure comments, place the comments inside that. That outputs root comments. And then we use generate nested list and pass in root comments. So that means comments here, in generatednestedlist, is the restructured, multidimensional array we'll be working with. The document is the document object model we'll be working with. The real challenge here is to output the correct HTML structure for a…