This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An ES6 utility function for finding the nth-max value in an array. | |
*/ | |
let nthMax = (array, nth = 1) => { | |
if(nth > (array.length - 1)) { | |
throw new Error('Nth max value exceeds array size'); | |
} | |
let newArr = array, | |
i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Based on the work of Nicholas C. Zakas | |
* https://github.com/nzakas/computer-science-in-javascript/ | |
*/ | |
class Node { | |
constructor(value = null, left = null, right = null) { | |
this.value = value; | |
this.right = right; | |
this.left = left; |