[Solved] Filtering data using ‘AND’ condition of inputs given

Instead of using map on filtered you might wana use every instead: function filterYes(data, keys){ return data.filter(data => keys.every(key => data[key] === “yes”)); } I guess your data is an array (cause you call map on it) otherwise its a bit more complicated: function filterYes(data, key){ return Object.assign({}, …Object.entries(data).filter(([key, value]) => keys.every(key => value[key] === … Read more

[Solved] Merging Object In Array In JavaScript if Conditions Are Met [closed]

Here is the steps which you need to follow. Create a new array for merged objects Iterate the array Find the item which you’re looking for merge with the existing object to the filtered object append to new object done. let json = [{“id”:191,”warehouse_id”:24,”ingredient_id”:65,”expiration_date”:”2019-07-31″,”available_stocks”:7,”ingredient”:{“id”:65,”name”:”erg”,”SKU”:”1000064″,”default_unit”:{“id”:26,”name”:”Milliliter”},”purchase_price”:50}},{“id”:192,”warehouse_id”:24,”ingredient_id”:66,”expiration_date”:”2019-09-18″,”available_stocks”:33994,”ingredient”:{“id”:66,”name”:”gvf”,”SKU”:”1000065″,”default_unit”:{“id”:27,”name”:”Gram”},”purchase_price”:60}},{“id”:193,”warehouse_id”:24,”ingredient_id”:67,”expiration_date”:”2019-09-19″,”available_stocks”:43996,”ingredient”:{“id”:67,”name”:”fwefe”,”SKU”:”1000066″,”default_unit”:{“id”:26,”name”:”Milliliter”},”purchase_price”:70}},{“id”:52,”outlet_item_id”:null,”warehouse_item_id”:191,”ingredient_id”:65,”quantity”:7,”total_in_lowest”:0,”stock_on_hand”:0,”adjustment_price”:0,”soh_total_in_lowest”:0,”unit_price”:50,”difference”:0,”difference_in_lowest”:0}]; // new array after merging the objects let desiredArray = []; … Read more

[Solved] Filter 2D array using another 2D array where differently keyed column values intersect

Here is a way to do it : First, you need to extract the firepack_id you need to look for, then you need to loop through $arr1 and check if Firepack_sn is the same than than one of the firepack_id you extracted before, if yes, then you add it to an array. $arr1 = json_decode(‘[{“Firepack_sn”:”20012205″,”Installation_Date”:””,”Type”:”EH”,”Standard”:”VAS”,”Capacity_m3h”:”81″,”Pressure_bar”:”3,4″,”Rpm”:”2930″,”Power_kw”:”72″,”Pump_Type”:”KSB … Read more