Last active
January 28, 2016 22:15
-
-
Save guzart/e9bb5adee7840f527236 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
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(function (person) { | |
| return person.get('name'); | |
| }); | |
| const groupTwoNames = groupTwo.map(function (person) { | |
| return person.get('name'); | |
| }); | |
| const namesInCommon = groupOneNames.filter(function (g1Name) { | |
| return groupTwoNames.indexOf(g1Name) >= 0; | |
| }); | |
| return namesInCommon; | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| const namesInCommon = groupOneNames.filter(function (g1Name) { | |
| return groupTwoNames.indexOf(g1Name) >= 0; | |
| }); | |
| return namesInCommon; | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| const doesGroupTwoHasName = function (name) { | |
| return groupTwoNames.indexOf(g1Name) >= 0; | |
| }; | |
| const namesInCommon = groupOneNames.filter(function (g1Name) { | |
| return doesGroupTwoHasName(g1Name); | |
| }); | |
| return namesInCommon; | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function findCommonNames(groupOne, groupTwo) { | |
| const doesGroupTwoHasName = function (name) { | |
| return groupTwo.indexOf(g1Name) >= 0; | |
| }; | |
| const commonNames = groupOne.filter(function (g1Name) { | |
| return doesGroupTwoHasName(g1Name); | |
| }); | |
| return commonNames; | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonNames(groupOneNames, groupTwoNames); | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function doesListHasItem(list, item) { | |
| return list.indexOf(item) >= 0; | |
| } | |
| function findCommonNames(groupOne, groupTwo) { | |
| const doesGroupTwoHasName = function (name) { | |
| return doesListHasItem(groupTwo, name); | |
| }; | |
| const commonNames = groupOne.filter(function (g1Name) { | |
| return doesGroupTwoHasName(g1Name); | |
| }); | |
| return commonNames; | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonNames(groupOneNames, groupTwoNames); | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function doesListHasItem(list) { | |
| return function (item) { | |
| return list.indexOf(item) >= 0; | |
| }; | |
| } | |
| function findCommonNames(groupOne, groupTwo) { | |
| const doesGroupTwoHasName = doesListHasItem(groupTwo); | |
| const commonNames = groupOne.filter(function (g1Name) { | |
| return doesGroupTwoHasName(g1Name); | |
| }); | |
| return commonNames; | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonNames(groupOneNames, groupTwoNames); | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function doesListHasItem(list) { | |
| return function (item) { | |
| return list.indexOf(item) >= 0; | |
| }; | |
| } | |
| function findCommonNames(groupOne, groupTwo) { | |
| const doesGroupTwoHasName = doesListHasItem(groupTwo); | |
| const commonNames = groupOne.filter(doesGroupTwoHasName); | |
| return commonNames; | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonNames(groupOneNames, groupTwoNames); | |
| } |
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 getName(person) { | |
| return person.get('name'); | |
| } | |
| function doesListHasItem(list) { | |
| return function (item) { | |
| return list.indexOf(item) >= 0; | |
| }; | |
| } | |
| function findCommonItems(groupOne, groupTwo) { | |
| const isItemInGroupTwo = doesListHasItem(groupTwo); | |
| return groupOne.filter(isItemInGroupTwo); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonItems(groupOneNames, groupTwoNames); | |
| } |
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 getPropFromItem(prop, item) { | |
| return item.get(prop); | |
| } | |
| function getName(person) { | |
| return getPropFromItem('name', person); | |
| } | |
| function doesListHasItem(list) { | |
| return function (item) { | |
| return list.indexOf(item) >= 0; | |
| }; | |
| } | |
| function findCommonItems(groupOne, groupTwo) { | |
| const isItemInGroupTwo = doesListHasItem(groupTwo); | |
| return groupOne.filter(isItemInGroupTwo); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonItems(groupOneNames, groupTwoNames); | |
| } |
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 getPropFromItem(prop) { | |
| return function (item) { | |
| return item.get(prop); | |
| }; | |
| } | |
| const getName = getPropFromItem('name'); | |
| function doesListHasItem(list) { | |
| return function (item) { | |
| return list.indexOf(item) >= 0; | |
| }; | |
| } | |
| function findCommonItems(groupOne, groupTwo) { | |
| const isItemInGroupTwo = doesListHasItem(groupTwo); | |
| return groupOne.filter(isItemInGroupTwo); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonItems(groupOneNames, groupTwoNames); | |
| } |
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 getPropFromItem = prop => item => item.get(prop); | |
| const getName = getPropFromItem('name'); | |
| const doesListHasItem = list => item => list.indexOf(item) >= 0; | |
| function findCommonItems(groupOne, groupTwo) { | |
| const isItemInGroupTwo = doesListHasItem(groupTwo); | |
| return groupOne.filter(isItemInGroupTwo); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonItems(groupOneNames, groupTwoNames); | |
| } |
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 getPropFromItem = prop => item => item.get(prop); | |
| const getName = getPropFromItem('name'); | |
| const doesListHasItem = list => item => list.indexOf(item) >= 0; | |
| function findCommonItems(groupOne, groupTwo) { | |
| return groupOne.filter(doesListHasItem(groupTwo)); | |
| } | |
| function findNamesInCommon(groupOne, groupTwo) { | |
| const groupOneNames = groupOne.map(getName)); | |
| const groupTwoNames = groupTwo.map(getName); | |
| return findCommonItems(groupOneNames, groupTwoNames); | |
| } |
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 getPropFromItem = prop => item => item.get(prop); | |
| const getName = getPropFromItem('name'); | |
| const doesListHasItem = list => item => list.indexOf(item) >= 0; | |
| const findCommonItems = (g1, g2) => g1.filter(doesListHasItem(g2)); | |
| const getGroupNames = g => g.map(getName); | |
| const findNamesInCommon = (g1, g2) => findCommonItems(getGroupNames(g1), getGroupNames(g2)); |
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 getItemProp = prop => item => item.get(prop); | |
| const getItemName = getItemProp('name'); | |
| const isItemInList = list => item => list.indexOf(item) >= 0; | |
| const findCommonItems = (list1, list2) => list1.filter(isItemInList(list2)); | |
| const getNamesFromList = list => list.map(getItemName); | |
| const findNamesInCommon = (list1, list2) => findCommonItems(getNamesFromList(g1), getNamesFromList(list2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment