$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #234

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]
  1. Use queue.splice(0, 1)
  2. Use queue.slice(0, 2)
  3. Use queue.slice(2) here
  4. Use queue.splice(2) here
splice removes the items from the original array; slice returns a copy and leaves it untouched.
Play Problem Solving ▸