For Loops in JavaScript (OCR A-Level Computer Science): Quizzes
📚Quizzes
Practise the questions
10 questions from this quiz
ShowHide
Practise the questions
10 questions from this quiz
What are loops used for in JavaScript?
What are loops used for in JavaScript?
Repeat code a specific number of times
For what type of tasks are loops particularly useful?
For what type of tasks are loops particularly useful?
Tasks involving fixed repetitions
What are the three components of for loop syntax?
What are the three components of for loop syntax?
initialisation; condition; increment
In the example 'for (let i = 0; i < 5; i++)', what does 'i < 5' represent?
In the example 'for (let i = 0; i < 5; i++)', what does 'i < 5' represent?
The condition
How many times does the example loop 'for (let i = 0; i < 5; i++)' execute?
How many times does the example loop 'for (let i = 0; i < 5; i++)' execute?
5 times
What is a common mistake when writing for loops?
What is a common mistake when writing for loops?
Incorrect loop conditions
What must the loop condition ensure?
What must the loop condition ensure?
The loop can exit
For what type of tasks are loops best suited?
For what type of tasks are loops best suited?
Tasks with a fixed number of iterations
In the example, what does 'let i = 0' represent in the for loop syntax?
In the example, what does 'let i = 0' represent in the for loop syntax?
The initialisation
What does 'i++' do in the example 'for (let i = 0; i < 5; i++)'?
What does 'i++' do in the example 'for (let i = 0; i < 5; i++)'?
Increments i by 1 each iteration
