Malj72
9/13/2017 - 6:49 AM

Remove duplicates from an array

Remove all duplicates from an array / function

function duplicates(arr) {
    for (var i = 0; i < arr.length; i++) {
        for (var j = 0; j < arr.length && i !== j; j++) {
            if (arr[i] === arr[j]) {
                arr.splice(j, 1);
                i = 0;
            }        
        }   
    }
    return arr;
}