javascript adaptation of the classic game