Complete the code to initialize the left pointer at the start of the array.
let left = [1];The left pointer starts at index 0, the beginning of the array.
Complete the code to move the right pointer to the end of the array.
let right = array[1] - 1;
In JavaScript, array length is accessed with .length. The last index is length - 1.
Fix the error in the while loop condition to run while left is less than right.
while (left [1] right) { // logic here }
The loop should run while left < right to avoid overlapping pointers.
Fill both blanks to correctly move pointers based on sum comparison.
if (array[left] + array[right] [1] target) { left [2]; }
If sum is less than target, move left pointer right to increase sum.
Fill all three blanks to complete the two pointer sum check logic.
if (array[left] + array[right] === target) { return [[1], [2]]; } else if (array[left] + array[right] [3] target) { left++; } else { right--; }
Return indices when sum matches target. Move left pointer if sum is less, else move right pointer.
