- Make a drawing of your app. Simple "wireframes"
- Once you have a drawing, name the HTML elements you'll need to realize your vision
- For each HTML element ask: Why do I need this?
- This is your pseudocode
- Once we know why we need each element, think about how to implement the "Why" as a "How"
- Is there some state we need to initialize?
- Find all the 'events' (user clicks, form submit, etc) in your app. Ask one by one, "What happens when" for each of these events.
- Think about how to validate each of your steps
HTML Setup
- radio buttons for pokemon (same name for exclusive selection)
- button to 'catch' the pokemon
State
- caught for each pokemon
- encounters for each pokemon
- const pokedex = []
Events
- onClick
- send the selected ('caught') pokemon to the pokedex
- figure out which one is selected
- capture pokemon
- ++ captures state
- check captures state
- if 10, redirect
- otherwise generate more pokemon
- send the selected ('caught') pokemon to the pokedex
- onLoad
- generate pokemon
Functions
-
generateThreePokemon
- start with array of pokemon data
- Math.random() to get 3 random array indexes
- assure they're unique
- WHILE they're not unique, get three more random indexes (while loop)
- assure they're unique
- use the three indexes to get three pokemon
- ++ encountered property for all
- "is it in the pokedex yet? if not, add. if it is, encountered property is incremented -put em in the DOM
-
local storage utils
- getPokedex -encounteredPokemon -capturePokemon
-
capturePokemon(selectedPokemon)
- grab pokedex from local storage
- increment captured property for just the selected one