Week 3 — Choice statements, Booleans, Numbers and Loops
JavaScript topics
JavaScript examples
Slide set
Data types
Boolean logic
Variable types
- Numbers — a two number
arithmetic calculator.
- Boolean
- Datatype conversion
- Object literals —
example
- Typeof operator, undefinded and null types
Alert, prompt and confirm popups
- window.alert(String)
- window.prompt(String, optional_default_string)
- window.confirm(String)
Choice statements
Example programs.
- Using if statements
here.
- Using switch statements
here.
Loops
Example programs.
- Night out,
deciding what to do based on cash on hand using a nested if statement
program, and a while loop program
- While loop control statement
example.
Use the debugger to trace programs.