Trying to recreate the magical iOS game by the same name in JS