Created
July 17, 2018 13:52
-
-
Save adamgiese/2685853451c8810ed12277ddf6f757fa to your computer and use it in GitHub Desktop.
Declarative Arrays: Chain Restaurant
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 currentTime = 15; // 3:00 PM | |
const isOpen = ({hours: {open, close} }) => | |
currentTime > open && currentTime < close; | |
const isFood = ({cuisine}) => cuisine !== 'Coffee'; | |
const toName = ({name}) => name; | |
const openRestaurants = restaurants | |
.filter(isOpen) | |
.filter(isFood) | |
.map(toName) | |
; | |
console.log(openRestaurants); // ["Pizza Planet", "Bob's Burgers", "Monks Cafe"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment