Reading-Notes

Reading Notes Class 8

  1. What is an expression in JavaScript? At a high level, an expression is a valid unit of code that resolves to a value. There are two types of expressions: those that have side effects (such as assigning values) and those that purely evaluate. The expression x = 7 is an example of the first type. This expression uses the = operator to assign the value seven to the variable x. The expression itself evaluates to 7. The expression 3 + 4 is an example of the second type. This expression uses the + operator to add 3 and 4 together and produces a value 7. This needs to be part of a larger construct or you it will get immediately discarded.

  2. Why would we use a loop in our code? Loops offer a quick and easy way to do something repeatedly. You can think of a loop as a computerized version of the game where you tell someone to take X steps in one direction, then Y steps in another.
  3. When does a for loop stop executing? A loop stops executing either when it has reached its predetermined number of times to run a loop or by using a break statement
  4. How many times will a while loop execute? However many times you decide to program that loop to execute!

Additional Information/ Questions