Skip to content

Instantly share code, notes, and snippets.

@judearasu
Created March 8, 2020 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judearasu/e457183ede920b76dd24f195394f3084 to your computer and use it in GitHub Desktop.
Save judearasu/e457183ede920b76dd24f195394f3084 to your computer and use it in GitHub Desktop.
Find Intersection
function findIntersection(strArr) {
let result = [];
if (Array.isArray(strArr)) {
let arg1 = strArr[0].split(",").map(elem => elem.trim());
let arg2 = strArr[1].split(",").map(elem => elem.trim());
arg1.filter(a => {
if (arg2.includes(a)) {
result.push(a.trim());
}
});
}
if (result.length > 0) {
return result.join(",");
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment