I have two array available, selected which is having some values. I am having another array named finalAvailable in which I want all those from the available array at the same time also to remove those which are present in selected array. An example is shown below
var available = ["A", "B", "C", "D", "E"];
var selected = ["B", "C"];
so the finalAvailable array will be like
var finalAvailable = ["A", "D", "E"];
I have written a code for achieving this and its working fine, but the problem is since I am using Lo-dash within my project my team lead ask whether there is any function available to achieve this using Lo-dash, I searched but could find anything, I don't know whether I am missing anything.
Can anyone tell me whether there is anything similar available in Lodash
My code is as given below
var available = ["A", "B", "C", "D", "E"];
var selected = ["B", "C"];
var finalAvailable = [];
for (var i = 0; i < available.length; i++) {
var flag = true;
for (var j = 0; j < selected.length; j++) {
if (available[i] == selected[j]) {
flag = false;
}
}
if (flag) {
finalAvailable.push(available[i])
}
}