Ad
Code
Diff
  • function getMin(list) {
        let ret = list.reduce((prev, curr) => {
            if (curr <= 0) return prev;
            return (prev <= 0) ? curr : Math.min(curr, prev);
        }, -1);
        return ret > 0 ? ret : 0;
    }
    • function getMin(list) {
    • let ret = list.reduce((prev, curr) => {
    • if (curr >= 1) {
    • if (prev <= 0) {
    • return curr;
    • }
    • else {
    • return Math.min(curr, prev);
    • }
    • }
    • return prev;
    • if (curr <= 0) return prev;
    • return (prev <= 0) ? curr : Math.min(curr, prev);
    • }, -1);
    • return ret >= 1 ? ret : 0;
    • return ret > 0 ? ret : 0;
    • }