What's the best (cleanest) way to provide this sort of logic?
var colors = ["red","white","blue"];
logic(colors,["red","green"]); //false
logic(colors,["red"]); //true
logic(colors,["red","purple"]); //false
logic(colors,["red","white"]); //true
logic(colors,["red","white","blue"]); //true
logic(colors,["red","white","blue","green"]); //false
logic(colors,["orange"]); //false
Possibly using underscore.js?
Assuming each element in the array is unique: Compare the length of
hand
with the length of the intersection of both arrays. If they are the same, all elements inhand
are also incolors
.DEMO
Maybe difference is what you are looking for: