JavaScript Loops Worksheet
Questions
Question 1
What is the difference between a while loop and a for loop?
A while loop will run as long as the condition is equal to true. A for loop has multiple parts in the conditions that allow it to iterate over things.
Question 2
What is an iteration?
Its the single execution of the loops body.
Question 3
What is the meaning of the current element in a loop?
It is the current value thats processed in a iteration of a loop. If an array element is assigned to the loop/counter variable, that would be the current element.
Question 4
What is a 'counter variable'?
A counter variable is the i or x variable in the condition statement for the loop.
Question 5
What does the break; statement do when used inside a loop?
It is used to exit a loop despite the conditions.
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.