Skip to content

Instantly share code, notes, and snippets.

@DewofyourYouth
Created November 15, 2023 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DewofyourYouth/f69d840c1f605724a10729d7cf3997e6 to your computer and use it in GitHub Desktop.
Save DewofyourYouth/f69d840c1f605724a10729d7cf3997e6 to your computer and use it in GitHub Desktop.
Better Choose Adventure
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