loading...

Discussion on: Basic Javascript: Removing Duplicates from an Array

Collapse
verdotte1 profile image
Verdotte

This implementation maybe helpful for beginners

function removeDuplicates(array){
 let new = []
 for(let val of array) {
  if (!isExist(new, val)) 
  new.push(val)
 }
 return new
}

function isExist (arr, val){
 for (let i of arr){
  if (i == val) return true
 }
 return false
}