An online markdown blog and knowledge repository.
Presenter: Monika Davies
Topic: Breaking down problems in javascript
This is an important web development skill.
Demo app will be to build Rock-paper-scissors, an HTML, CSS, and JavaScript single-page app.
Get requirements:
Consider UI Structure:
Consider Styling:
Consider Functionality and Dynamic Aspects:
Consider Artifacts:
Input type elements aren't that much different than Button elements, and can be set written to handle events like a button would.
Use ID's to enable elements that can display data and have it get dynamically updated e.g. Player Score.
Find all items with class name 'class' and store them in a variable: const buttons = document.querySelectAll('.class')
Add an event listener with button.addEventListener('click', handlerFunction)
Use Console.Log to verify event listeners are working.
Need to select an item randomly from a string array? Use Random, but put its bounds between 0 and max index of the array, then use array indexing to get the item from the array with the random index number.
Is there a large matrix of possible outcomes:
Player.selection === Computer.selection
which handles 3 possible conditions in one.Back to PPH Index
Return to Root README