Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove duplicate name from array javascript

const allNames = ['Nathan', 'Clara ', 'Nathan', 'Fowler', 'Mitchell', 'Fowler', 'Clara ', 'Drake', 'Fowler', 'Clyde ', 'Mitchell', 'Clyde '];

function checkName(names) {
  const uniqueName = [];
  for (let i = 0; i < names.length; i++) {
    const nameIndex = names[i];
    if (uniqueName.includes(nameIndex) == false) {
      uniqueName.push(nameIndex);
    }
  }
  return uniqueName;
}

const uniqueNames = checkName(allNames);
console.log(uniqueNames);
Source by www.javascripttutorial.net #
 
PREVIOUS NEXT
Tagged: #remove #duplicate #array #javascript
ADD COMMENT
Topic
Name
4+9 =