JS - Nodes
Nodes
Nodes are building blocks to more complicated data structures, formed when many Nodes are linked together.
- Data helps to store information
- Next is a link to other Nodes for easier traversal
Test the Node Class:
Example 1: Ice Cream Flavors
Imagine we are working at an ice cream shop that sells three flavors: strawberry, vanilla, and coconut.
The signature sundae is made of these three flavors in order. We can use Javascript Nodes for this.
Example 2: Siblings
Link together the 3 siblings nodes: youngest -> middle -> oldest.
Then, iterate through the nodes, starting at youngest to get oldest‘s name.