QuestenaPractice that shows what to review next
Question 108

An array has length n. A loop starts i at 0, increments i by 1, and must visit each valid index exactly once. Which condition is correct?

  1. i <= n
  2. i > n
  3. i >= n
  4. i < nCorrect answer

Explanation

Valid indexes for a nonempty array of length n run from 0 through n - 1, so i < n stops immediately before the out-of-range index n. Using i <= n permits one extra body execution and is the classic boundary mistake.

Continue with this test

Start practice
Question 108: An array has length n. A loop starts i at 0, increments i… · JavaScript Fundamentals · Questena