Re-adding the whole window makes the pass quadratic and doubles the total.
Acceptance criteria
- 1.#out should show best 9.
Re-adding the whole window makes the pass quadratic and doubles the total.
const items = [2, 1, 5, 1, 3, 2]; let sum = 0; for (let i = 0; i < 3; i++) sum += items[i]; let best = sum; for (let i = 3; i < items.length; i++) { sum += items[i]; best = Math.max(best, sum); } document.querySelector('#out').textContent = "best " + best;
Output ready when you are
Press Run to render your code, or Submit to validate your solution.