Last active
August 23, 2018 01:12
-
-
Save luislobo14rap/583a3b8407f5e4406eb8fa9129b676b0 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
// arrayIntersection.js v1 | |
function arrayIntersection(arrayA, arrayB) { | |
let newArray = []; | |
for (let i = 0; i < arrayA.length; i++) { | |
if (arrayB.indexOf(arrayA[i]) > -1) { | |
newArray.push(arrayA[i]); | |
}; | |
}; | |
return newArray; | |
}; | |
Array.prototype.intersection = function(arrayB) { | |
return arrayIntersection(this, arrayB); | |
}; |
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
// arrayIntersection.min.js v1 | |
function arrayIntersection(a,b){let c=[];for(let d=0;d<a.length;d++)-1<b.indexOf(a[d])&&c.push(a[d]);return c}Array.prototype.intersection=function(a){return arrayIntersection(this,a)}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment