Get Element Ancestors

# Introduction In this lab, we will be exploring how to use JavaScript to retrieve all the ancestors of an element from the document root to the given element. This will involve using `Node.parentNode` and a `while` loop to navigate up the ancestor tree and `Array.prototype.unshift()` to add each new ancestor to the start of an array. By the end of the lab, you should have a solid understanding of how to retrieve element ancestors using JavaScript.

|60 : 00

Click the virtual machine below to start practicing