Created
December 12, 2017 04:16
-
-
Save martinandersen3d/3de7d509699d1fd41fa6807cdbb989fb to your computer and use it in GitHub Desktop.
Compare two arrays, arrA must have all the items that is in arrB
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
/** | |
* Returns TRUE if the first specified array contains all elements | |
* from the second one. FALSE otherwise. | |
* | |
* @param {array} superset | |
* @param {array} subset | |
* | |
* @returns {boolean} | |
*/ | |
function arrayContainsArray (superset, subset) { | |
if (0 === subset.length) { | |
return false; | |
} | |
return subset.every(function (value) { | |
return (superset.indexOf(value) >= 0); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment