Ad
Code
Diff
  • 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;
        }, -1);
        return ret >= 1 ? ret : 0;
    }
    • var getMin = function (list){
    • var min = Number.MAX_VALUE;
    • for (var i = 0; i < list.length; i++) {
    • if (+list[i] <= 0) {
    • continue;
    • }
    • min = Math.min(min, +list[i]);
    • }
    • return min = min === Number.MAX_VALUE ? 0 : min;
    • 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;
    • }, -1);
    • return ret >= 1 ? ret : 0;
    • }