a function - 2 arrays : costPrice & productAndQty - trying to search all the product codes of same type in productAndQty and return a list of cost prices.
/**
* productAndQty : subscription-id, productcode, s,m,l,xl
* costprice: productcode, cp-s, cp-m ....... soo on!
*/
function getSupply(productAndQty,costPrice){
/**totalQtyAsProduct is the final array */
var totalQtyAsProduct = [];
/**co[0] is product code */
costPrice.forEach(function(co){
var tempPQ = productAndQty.filter(function(po){
return po[1]==co[0];
});
c(tempPQ);
c(tempPQ!=[]);
if(tempPQ!=[]){
totalQtyAsProduct.push(calcSupply(tempPQ,costPrice));
}
});
return totalQtyAsProduct;
}
but if(tempPQ!=[]) always return true; when I console.log(tempPQ), there are many [] that i dont want to pass to next function!