Last active
January 26, 2020 10:40
-
-
Save alldayalone/b0baaf756faf3d4ca3c623b56e4069c2 to your computer and use it in GitHub Desktop.
Difference
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 difference(a, b) { | |
var result = []; | |
for (var i = 0; i < a.length; i++) { | |
if (b.indexOf(a[i]) === -1) { | |
result.push(a[i]); | |
} | |
} | |
return result; | |
} | |
console.log(difference([1, 3, 2, 4, 5], [1, 5, 4])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment