JavaScript implementation of Game of Nim