reading-notes

Class 8 - Operators and Loops

JS code

Lab 8 - Operators and Loops

Requirements

  1. Add validation on one of the user inputs.
    • Keep asking until an acceptable value is entered.
  2. Show an image related to your page’s topic, repeated within your page.
    • Prompt the user with a relevant question for a number (e.g.: “How many cats do you want?” or “What star rating would you give, 1-5?”)
    • Use a loop in your JavaScript code to show the image that many times.
    • How could you use functions to make your code more readable?

Written Class Notes

Read 8 - Operators and Loops Reflection and Discussion

Resources Link/Pages

  1. Expressions and Operators
  2. Loops

Answer

  1. What is an expression in JavaScript?
    • Multiple operations/code that gives something a value
  2. Why would we use a loop in our code?
    • It is a quick and easy way to do something repeatedly
  3. When does a for loop stop executing?
    • When the value of condition stops being true
  4. How many times will a while loop execute?
    • It will execture as long as condition evalutes to be true