Complete the code to stop the loop when i equals 3.
for (let i = 0; i < 5; i++) { if (i === 3) { [1]; } console.log(i); }
The break statement stops the loop immediately when the condition is met.
Complete the code to exit the while loop when count reaches 5.
let count = 0; while (true) { if (count === 5) { [1]; } console.log(count); count++; }
The break statement exits the infinite while loop when count is 5.
Fix the error in the code to stop the loop when num is 10.
for (let num = 0; num < 20; num++) { if (num === 10) { [1]; } console.log(num); }
Using break correctly stops the loop when num reaches 10.
Fill both blanks to stop the loop when the letter is 'c'.
const letters = ['a', 'b', 'c', 'd']; for (let i = 0; i < letters.length; i++) { if (letters[i] [1] 'c') { [2]; } console.log(letters[i]); }
The condition letters[i] === 'c' checks for 'c', and break stops the loop when found.
Fill all three blanks to stop the loop when the number is greater than 7.
const numbers = [3, 5, 8, 10]; for (const num [1] numbers) { if (num [2] 7) { [3]; } console.log(num); }
Use for...of to loop over array values, check if num > 7, and use break to stop the loop.
