Created
          July 30, 2019 10:19 
        
      - 
      
 - 
        
Save PrimeTimeTran/d197b7f8bd1e42540fa1e63c5dfb597d to your computer and use it in GitHub Desktop.  
  
    
      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
    
  
  
    
  | const girlfriends = [ | |
| { isHappy: false, name: 'Binna', likesMovies: false, likesFlowers: true, favoriteFlowerColor: 'red' }, | |
| { isHappy: true, name: 'Vivian', likesMovies: false, likesFlowers: true }, | |
| { isHappy: false, name: 'Tram', likesMovies: true, likesFlowers: false }, | |
| { isHappy: true, name: 'Diep', likesMovies: true, likesFlowers: true }, | |
| ] | |
| function takeToMovie(girlfriend) { | |
| console.log('Loi is taking ' + girlfriend.name + ' to the movies') | |
| } | |
| function buyFlowers(girlfriend) { | |
| console.log('Loi is buying ' + girlfriend.favoriteFlowerColor + ' ' + girlfriend.name + ' flowers.') | |
| } | |
| function makeHappy(girlfriend) { | |
| if (girlfriend.isHappy) { | |
| console.log(`${girlfriend.name} already happy!`) | |
| } else { | |
| console.log(`${girlfriend.name} is unhappy!`) | |
| if (girlfriend.likesMovies) { | |
| takeToMovie(girlfriend) | |
| } | |
| if (girlfriend.likesFlowers) { | |
| buyFlowers(girlfriend) | |
| } | |
| } | |
| } | |
| girlfriends.map(makeHappy) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment