let arr = [1, 2, 2, 4, 3, 3, 2 , 3, 6, 8, 5, 12, 2, 2, 4];
function removeDuplicate(arr) {
const newArr = []
const newArr1 = []
arr.forEach(item => {
if (!newArr.includes(item)) {
newArr.push(item)
} else {
newArr1.push(item)
}
})
if (newArr.length > 0) {
for (let i=newArr.length-1; i>= 0; i--) {
for (let j=0; j< newArr1.length; j++) {
if (newArr[i] == newArr1[j]) {
newArr.splice(i, 1)
}
}
}
}
console.log(newArr) // [1, 6, 8, 5, 12]
return newArr
};