JavaScript Loops Worksheet
Questions
Question 1
What is the difference between a while loop and a for loop?
A while loop continues to execute as long as the condition is true, whereas a for loop is used when the number of iterations is known.
Question 2
What is an iteration?
This is a single pass through the code in a loop.
Question 3
What is the meaning of the current element in a loop?
The current element in a loop refers to the item or value that the loop is processing during an iteration.
Question 4
What is a 'counter variable'?
A counter variable is used to keep track of the number of times a loop has executed.
Question 5
What does the break; statement do when used inside a loop?
This statement terminates the loop it's used in.
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.