Skip to content

Instantly share code, notes, and snippets.

@guzart
Last active January 28, 2016 22:15
Show Gist options
  • Select an option

  • Save guzart/e9bb5adee7840f527236 to your computer and use it in GitHub Desktop.

Select an option

Save guzart/e9bb5adee7840f527236 to your computer and use it in GitHub Desktop.
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;
}
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;
}
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;
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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));
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