I am using angular as front end. I have below array of strings. I want to filter this "array" with matched keys of another "(key,value) objects".
String Array:
var stringArr = ["vijay-1110","viki-1100","ram-2110","mark-2100"]
(key,value) Objects:
var obj = {"viki-1100":6,"mark-2100":2}
To return only the non matched keys from stringArr,So desired output:
var result = ["vijay-1110","ram-2110"]
I haven tried the below code which doesnot return the desired output?
var filterFunction = function(stringArr,obj){
if(angular.equals({}, obj)){
return stringArr;
}
else{
_.each(stringArr,function(input,index){
Object.keys(obj).forEach(function(key) {
if(input === key){
stringArr.splice[index,1];
}
});
});
return stringArr;
}
this wont filter the stringArr, It always return all the results in stringArr?