---
# System prepended metadata

title: 'Acadia Studio Fun Exercise #1'

---

# Acadia Studio Fun Exercise #1 - Le

Imagine you have a set of nodes with each node containing a word and a taxonomy (based on a color). Please write a method that will traverse through the nodes until you find the node with name Canada and return the taxonomy (color). 

![](https://i.imgur.com/ZUBamkg.png)
```
class Node {
    name: string
    color: string
    nextNodes: Node[]
    
    constructor(name:string, color:string, nextNodes:Node[])    {
        this.name = name;
        this.color = color;
        this.nextNodes = nextNodes;
    
    }
}



function main(){

  
  const motocycleNode = new Node("Motocycle","purple",[])
  const boatNode = new Node("Boat","purple",[motocycleNode])
  const startNode = new Node("","",[boatNode]);
  
  findNode(startNode, "Motocycle");

}

function findNode(startNode: Node, destinationName:string):string {
    if(startNode.name === destinationName) return startNode.color;
    for(const node of nodes.nextNodes){
       findNode(node)
    }
}