Created
November 15, 2023 15:00
-
-
Save DewofyourYouth/f69d840c1f605724a10729d7cf3997e6 to your computer and use it in GitHub Desktop.
Better Choose Adventure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const adventureRouter = new Map([ | |
["find the Holy Grail", goToGrailQuest], | |
["save Princess Peach", goToMarioWorldQuest], | |
["save Princess Zelda", goToLegendOfZeldaQuest], | |
]); | |
function ChooseAdventure({ adventurer, choice }) { | |
return ( | |
<div id="adventure"> | |
<div> | |
Howdy there {adventurer.name}! Are you ready to {choice}? | |
<button onClick={() => adventureRouter.get(choice)(adventurer)}> | |
Yes | |
</button>{" "} | |
<button onClick={changeAdventure}>Change Adventure</button> | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment