Created
          April 14, 2017 02:56 
        
      - 
      
- 
        Save erkobridee/612a00a94b67671c9d757784a537b0d3 to your computer and use it in GitHub Desktop. 
    given a array of numbers, using Array.reduce return an array of uniques numbers
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function unique(array) { | |
| return array.reduce(function(acc, item){ | |
| if(!acc.find(function(element){ return element === item; })){ | |
| acc.push(item); | |
| } | |
| return acc; | |
| }, []); | |
| } | |
| var numbers = [1,1,2,3,4,4]; | |
| console.log(unique(numbers)); // [1,2,3,4] | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment