Complete the code to initialize the left pointer at the start of the array.
let left = [1];The left pointer should start at index 0 to point to the first element of the array.
Complete the code to initialize the right pointer at the end of the array.
let right = [1];The right pointer should start at the last valid index, which is array.length - 1.
Fix the error in the while loop condition to continue while left is less than right.
while (left [1] right) { // logic here }
The loop should run while left is strictly less than right to avoid overlap.
Fill both blanks to move the pointers correctly: increment left and decrement right.
left[1]; right[2];
Use ++ to move left pointer forward and -- to move right pointer backward.
Fill all three blanks to create a two-pointer loop that sums pairs and moves pointers accordingly.
while (left [1] right) { const sum = array[left] + array[right]; if (sum [2] target) { left[3]; } else { right--; } }
The loop runs while left is less than right. If sum is greater than target, move right pointer left. Otherwise, move left pointer right using ++.
