final code for group project

i translated the pseudocode into code.  it works in node, not sure if
my assert function is correct however.