# How's Math.min.apply getting a minimum value other than zero?

• How to obtain a minimum value not `0``4` ?

I mean, you need a minimum value other than zero.

``````let obj = {
0: 124,
1: 4,
2: 14,
3: 0,
4: 32,
5: 78,
};
let all = Object.keys(obj).map(function(key){ return obj[key]; });
let min = Math.min.apply(null, all);
let max = Math.max.apply(null, all);
console.log(min, max);``````

• So use it. `filter` and clean up zeros.

``````let obj = {
0: 124,
1: 4,
2: 14,
3: 0,
4: 32,
5: 78,
};
let all = Object.keys(obj).map(key => obj[key]).filter(key => key != 0);
let min = Math.min.apply(null, all);
let max = Math.max.apply(null, all);
console.log(min, max);``````

It's disgusting, if you want to solve it with help. `map`F

``````let obj = {
0: 124,
1: 4,
2: 14,
3: 0,
4: 32,
5: 78,
};
let min = Math.min(...Object.values(obj).map(value => value ? value : (Math.min(...Object.values(obj)) ?  Math.min(...Object.values(obj)) : Math.max(...Object.values(obj)))))
let max = Math.max(...Object.values(obj).map(value => value ? value : (Math.max(...Object.values(obj)) ?  Math.max(...Object.values(obj)) : Math.min(...Object.values(obj)))))
console.log(min, max)``````

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2