Last active
September 30, 2023 03:18
-
-
Save simonrentzke/5856414 to your computer and use it in GitHub Desktop.
Array of array subtraction
This file contains 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 remove_selected_from_options(arr1, arr2) { | |
var filtered_options = []; | |
for (var i=0; i < arr1.length; i++) { | |
var included = false; | |
for (var z=0; z < arr2.length; z++) { | |
if (arr2[z][0] == arr1[i][0]) { | |
included = true; | |
break; | |
} | |
} | |
if (included == false) { | |
filtered_options.push(arr1[i]); | |
} | |
} | |
return filtered_options | |
} | |
var a = [[1, 'cat'], [2, 'dog'], [3, 'squirrel']]; | |
var b = [[1, 'cat'], [2, 'dog']]; | |
remove_selected_from_options(a, b); |
Author
simonrentzke
commented
Jun 25, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment