Let's Improve on the Ice Cream Example

  1. Progressive Enhancement with JS. Good news! We are already doing 'progressive enhancement' and using JavaScript to set things up (using JS to "hide" the options when the page loads). If, for some reason, JS is broken, then the whole form will be displayed and can be used.
  2. DRY (Don't Repeat Yourself) — use loops! Instead of selecting input elements separately and adding 'click' listener to each one as well as the logic of showing or hiding options, can we select the input elements and loop through them?
  3. DRY (Don't Repeat Yourself) — use functions!