Tile matching game in JavaScript