Remove Duplicates from Array

by Jithin Raj P R

JavaScript

const numArray = [1, 2, 2, 3, 4, 4, 5];

function removeDuplicate(numArray){
  const result = []

  for(let i = 0; numArray.length > i; i++){
    if(!result.includes(numArray[i])){
      result.push(numArray[i])
    }
  }

  return result;
}

console.log(removeDuplicate(numArray));

// output 
//  [1, 2, 3, 4, 5]