I have a collection of arrays in javascript and I need to perform some calculations.
Here is how my array looks:
https://i.sstatic.net/m0tSw.png
In each array: - The first value represents a code. - The second value indicates the size. - And the third value denotes the count.
My objective is to identify all groups where the counts are all 0.
For instance:
- If "NVY" "S" has a count of 0 (not 28), then I want to retrieve ["sjm-NVY"];
Here's what I've attempted so far:
var a = [];
$.each(arr[21].splits, function(idx, val) {
console.log(val);
var current_code = arr[21].splits[idx][0];
a[current_code] = [];
a[current_code].push(arr[21].splits[idx]);
});
However, I haven't been able to find the correct solution. Thank you for any help!
The dataset:
{"code":"sjm","splits":[["FOG","L","0"],["FOG","XL","-1"],["FOG","XXXL","2"],["FOG","S","7"],["FOG","M","0"],["FOG","XXL","6"],["BLK","LT","30"],["BLK","XLT","23"],["BLK","XXXLT","0"],["BLK","L","102"],["BLK","XL","302"],["BLK","XXXL","64"],["BLK","S","25"],["BLK","XXLT","0"],["BLK","M","485"],["BLK","XXL","159"],["BGE","L","106"],["BGE","XL","41"],["BGE","XXXL","15"],["BGE","S","4"],["BGE","M","39"],["BGE","XXL","0"],["RED","L","36"],["RED","XL","41"],["RED","XXXL","8"],["RED","S","5"],["RED","M","19"],["RED","XXL","2"],["NVY","L","0"],["NVY","XL","0"],["NVY","XXXL","0"],["NVY","S","28"],["NVY","M","0"],["NVY","XXL","0"]]}
P.S There are no color codes on the screen above where all values in the group are 0, hence nothing to display.