Which fix removes the bug?
const queue = [1, 2, 3, 4]; const preview = queue.splice(0, 2); console.log(queue); // expected [1, 2, 3, 4]
- Use
queue.splice(0, 1) - Use
queue.slice(0, 2) - Use
queue.slice(2)here - Use
queue.splice(2)here
splice removes the items from the original array; slice returns a copy and leaves it untouched.
Play Problem Solving ▸