Write preOrder(callback) that also accept a callback as a parameter.
traverse the tree in their respective depth-first order and pass each node to the provided callback. The functions should throw an Error if no callback is given as an argument, like with levelOrder.
Write
preOrder(callback)
that also accept a callback as a parameter.traverse the tree in their respective depth-first order and pass each node to the provided callback. The functions should throw an Error if no callback is given as an argument, like with levelOrder.