Class 8 - Operators and Loops

Lab 8 - Operators and Loops
Requirements
- Add validation on one of the user inputs.
- Keep asking until an acceptable value is entered.
- 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
- While loop funs when true.
while (test expression){console.log(); x+3}
|| is logical OR
&& is logical AND
! is logical NOT
!== not strictly
!= not loosely
for (declare){} inside declare ex: let i=0;=intial value i <10;condition we are checking i ++ incremeater
Read 8 - Operators and Loops Reflection and Discussion
Resources Link/Pages
- Expressions and Operators
- Loops
Answer
- What is an expression in JavaScript?
- Multiple operations/code that gives something a value
- Why would we use a loop in our code?
- It is a quick and easy way to do something repeatedly
- When does a for loop stop executing?
- When the value of condition stops being true
- How many times will a while loop execute?
- It will execture as long as condition evalutes to be true