Practicing Traverse in JS