Closed pmander90 closed 9 years ago
// Distinct List Challenge // Remove duplicate elements from an array function removeDuplicate(array){ var distinct = [] var check = true for(var i=0; i<array.length; i++){ for(var j=0; j<distinct.length; j++){ if (array[i] === distinct[j]) { check = false break; } else { check = true } } if (check) { distinct.push(array[i]) } } return distinct; } var arr = [1,2,1,2,3,4] console.log(arr) console.log(removeDuplicate(arr))