I need to manipulate an array where elements are in increments of 5, and I specifically need to drop the 3rd and 4th elements.
Currently, I have a solution using two separate for-loops, but I believe there might be a more efficient or concise approach. Any suggestions?
const arr = ["good","good""bad","bad","good","good","good","bad","bad","good",];
// removing every 3rd element out of 5
for (let i = 2; i <= arr.length; i += 4) {
arr.splice(i, 1);
}
// dropping every 3rd element out of 4
for (let i = 2; i <= arr.length; i += 3) {
arr.splice(i, 1);
}
console.log(arr)
// expected result: ["good","good","good","good","good","good"]