Day 7 - Conditionals and form controls
Housekeeping
- Updated requirements for Assignment 2
1. Forms and Javascript
Demo: Adding Machine
Activity: Creating forms
In groups of 2-3:
- Pick one of the functions included in this Activity;
- Follow the provided instructions to:
- In the HTML:
- Create a
<form>
element that contains the required fields for the user to enter the function inputs; - Create a
<p>
that will store the form output after submission;
- Create a
- In the Javascript:
- Create variables for
form
andoutput
(the paragraph); - Add a
submit
event listener that invokes your chosen function; - Replace the hard-coded input variables with ones entered in the form;
- Output the result to the
output
element (the paragraph) instead of logging it to the console.
- Create variables for
- In the HTML:
2. Booleans and conditional code
Demo: Refactor temperature calculator
Using booleans and conditional statements convert the toCelcius
function so that it works both ways:
- Add
<select>
menu to selectto-celcius
orto-fahrenheit
; - Refactor function to make the correct calculation, based on the menu selection.
3. Lab Time
Prep
Forms
- Reading list
- Watch list:
- HTML Forms by Net Ninja
Conditional code
- Reading list
- Watch list
- JavaScript
if
/else
Tutorial by Programming with Mosh
- JavaScript