Javascript implementation of a maze generator