Some computer science review (data structures, algos) in Javascript