Created
          March 13, 2018 01:29 
        
      - 
      
 - 
        
Save liseferguson/5a0397ddc260a45507ab0ca8ebccfad7 to your computer and use it in GitHub Desktop.  
    Accessing arrays
  
        
  
    
      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 addToList(list, item) { | |
| list.push(item); | |
| return list; | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | |
| Nothing to see here! | |
| */ | |
| // tests | |
| function testAddToList() { | |
| const input1 = ['red', 'blue', 'green']; | |
| const input2 = 'pink'; | |
| const expected = ['red', 'blue', 'green', 'pink']; | |
| const result = addToList(input1, input2); | |
| if ( | |
| result && | |
| result.length && | |
| expected.length === result.length && | |
| expected.every(function(item) { | |
| return result.indexOf(item) > -1; | |
| }) | |
| ) { | |
| console.log('SUCCESS: `addToList` works!'); | |
| } else { | |
| console.error('FAILURE: `addToList` is not working'); | |
| } | |
| } | |
| testAddToList(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
https://repl.it/@liseferguson/Adding-array-items-drills