79263699

Date: 2024-12-09 02:26:42
Score: 1.5
Natty:
Report link

enter image description here

The splice function returns a deleted element or an empty array enter image description here The unshift function return value is array length

Maybe,you can change this code

if (index > -1) {
  console.log('index', index);
  advantages.splice(index, 1);
  console.log('advantages', advantages.length);
  advantages.unshift(type);
  console.log('advantages', advantages.length);
  this.setPurchaseAdvantages(advantages);
}

Both of these functions can change the original array, so you don't need to create a new array to operate

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: a human