Created
September 7, 2017 08:16
-
-
Save iamdey/1d47376665684f10cbcc92839a99c27e to your computer and use it in GitHub Desktop.
Caliopen favorite address
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
favoriteAddressFilter = (addresses, searchTerms) => addresses.reduce((acc, address) => { | |
if (!acc) { | |
return address; | |
} | |
if (address.startsWith(searchTerms) && !acc.startsWith(searchTerms)) { | |
return address; | |
} | |
if (!acc.is_primary && address.is_primary === true) { | |
return address; | |
} | |
return acc; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment