Good Day, I am trying to remove duplicate element from an array using the forEach
loop. But at this point in time i get some errors. Below are my codes
function removeDup(arr) {
let result = arr.forEach((item, index) => { if (index > 1) item.shift() });
return result;
}
I am not even sure if this code would work for removing duplicates because when i run it in a browser console
i get this error
if (index > 1) item.shift(); ^
TypeError: item.push is not a function
First of all, how do i fix this error and secondly would this code work for removing duplicates?