JS 4.3 Loops Flashcards
Define a ( while ) statement
A ( while ) statement creates a loop that executes a specified statement as long as the test condition evaluates to true.
What’s the difference between the ( do ) loop and the ( while ) loop?
The do while loop executes a block a code before the condition is tested. A while loop test its condition first before it executes a block of code.
What’s the syntax for a do ( while loop )?
The keyword do, followed by curly braces and then the keyword while followed by parentheses
What’s the syntax for a ( for loop)?
Use the keyword ‘for’, followed by parentheses, which hold the initial expression, condition expression and then the increment expression.
Define the ( break ) statement
Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement
As far as DRY code using JavaScript, what are three big principles?
- Reduce repetition of code in a program
- Loops help you write DRY code
- JavaScript functions embrace the DRY principle
Define the ( document.querySelector() ) method
This method returns the first element within the document that matches that specified selector or a group of selectors.