We've begun the work of beginning event driven programming (a form of asynchronous programming) by adding event listeners such that certain code is invoked when other actions happened. Now we take it a step farther and start to build a bridge toward:
- Making HTTP Requests (and receiving their responses)
- Comparing and contrasting 3 different approaches to asynchronicity:
- Callbacks
- Promises
- async/await
Make a little web app that has 2 user interface elements (these are actually provided):
- a text input element
- an output element
- Add an event listener such that when the text input has focus and the user presses enter,
- the text they've entered is used to search for a possible valediction, and
- that found valediction is displayed in the output element.
See Part 1 in action π¬:
- Modify the code you have for Part 2 such that the user's input is instead used to find possible valediction targets.
- These matching targets are displayed as buttons, and
- when one of the buttons is clicked,
- the valediction target displayed on the button is used to query for the corresponding valediction (similar to what you had in Part 1), which
- finally is displayed in the output element.
See Part 2 in action π¬:
- You may work in pair or trios, if you wish.
- Start with the provided code:
later.js- in theory, you need not even open this file. The information you need about it is available inmain.js's commentsmain.js- this is where you will do your workmain.css- puts on the fancypantsindex.html- the structure of the page, doesn't validate. you need not edit this file
- read the comments in
main.js, observing especially:- the documentation of the 2 provided functions at the top of the file:
later(targetQuery, callback)options(callback, query)
- the
TODOitems guiding you to the areas to start editing for Part 1
- the documentation of the 2 provided functions at the top of the file:
- you only need to edit
main.js - submit your
main.jscode to this assignment

