JavaScript Loops Worksheet
Questions
Question 1
What is the difference between a while loop and a for loop?
A for loop requires a counter variable - a while loop does not.
Question 2
What is an iteration?
An iteration refers to each execution of a loop code (which could potentially have many iterations before ending).
Question 3
What is the meaning of the current element in a loop?
The current element refers to the unique iteration's value from an array's data set.
Question 4
What is a 'counter variable'?
A counter variable is the starting point-reference for a loop's computation
Question 5
What does the break; statement do when used inside a loop?
It will terminate a loop after the first instance of a "true" boolean statement.
(a break is useful in conjunction with an if statement, in that it can be reserved for execution
if the programmer is looking to find an exact matching data value.)
(a break is useful in conjunction with an if statement, in that it can be reserved for execution
if the programmer is looking to find an exact matching data value.)
Coding Problems
Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.
Always test your work! Check the console log to make sure there are no errors.