Guest User

Untitled

a guest
Apr 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. const removedDuplicates=((arr)=>{
  2. const result = [];
  3. return (arr.reduce((all,item,index,arr) => {
  4. if(arr.indexOf(item)===index)
  5. {
  6. result.push(item)
  7. return result
  8. }
  9. return all
  10. },[]))})
  11.  
  12.  
  13. //Example
  14. const array1 = [1, 4, 9, 16, 4, 25 , 9, 16, 4, 18, 35, 23, 18];
  15. console.log(removedDuplicates(array1))
  16. //Ouput Array [1, 4, 9, 16, 25, 18, 35, 23]
Add Comment
Please, Sign In to add comment