1.

How to remove duplicate values in an array with JavaScript?

Answer»

There are two METHODS to remove duplicate CONTENT from an array such as USING a temporary array and a separate index.

Example

FUNCTION getUnique(arr){     
    let uniqueArr = [];    
     for(let i of arr) {
        if(uniqueArr.indexOf(i) === -1) {
            uniqueArr.push(i);
        }
    }
    console.log(uniqueArr);
}

const array = [1, 2, 3, 2, 3,4,5];
getUnique(array);



Discussion

No Comment Found