I have two arrays. Those are
let x = [1,2,0,4,7,8,9,1,1,1];
let y = [10,50,80,70,906,80,70,80,15,11]
Important : x = y, That means 1 = 10, 2 = 50, 0 = 80 etc...
I want to find minimum and maximum value of x array and want to get y values related to that data, as well as 0 values (min value should greater than 0 value)
expected output is:
let res = {
min: {
minVal: 1,
minvalues: [10, 80, 15, 11]
},
max: {
minVal: 9,
minvalues: [70]
}
empty: [80]
}
Here is what I tried. this way problem is I couldn't get only value from filter method it gives object
const res = x.map((key, index) => {
return {[key]: y[index]};
}, {});
let info = {
min : {},
max : {},
empty : {}
}
let min = Math.min.apply(this, x.filter(Number));
let max = Math.max(...x);
info.min['min'] = min
info.min['minVal'] = res.filter((el, idx) => el[min])`
labelsAndHistoDatadefined?