[Vuejs]-Issue removing first element of array with Javascript

0👍

you are geting an array when you are using this

let removedElement = advantages.splice(index, 1);
let advantages = ['liked', 'sendUnlimitedLikes', 'unlockSundays', 'getBoosted', 'filters', 'revealAllProfiles', 'wholeCountry', 'exlusiveBlogs'];
let type = 'getBoosted'; 
let index = advantages.indexOf(type); // Find the index of the element
if (index > -1) {
  let removedElement = advantages.splice(index, 1)[0]; // Remove the element and store it
  advantages.unshift(removedElement); // Add the element to the start of the array
}

console.log(advantages);

Leave a comment