Me trying to solve turtle_crossing algorithm at JavaScript