Open greatInvoker opened 1 year ago
const arr = [10, 21, 0, -7, 35, 7, 9, 23, 18];
arr.reduce((pre,cur,index)=>{ return cur>0&cur<pre.val ? {i:index,val:cur} : pre },{i:-1,val:Infinity})
const ary = [10, 21, 0, -7, 35, 7, 9, 23, 18];
function getIndex(ary) {
const result = ary.reduce(
(acc, cur, index) =>
acc.value > cur && cur > 0 ? { value: cur, index } : acc,
{ value: Infinity, index: -1 }
);
return result.index;
}
const arr = [10, 21, 0, -7, 35, 7, 9, 23, 18];
const min = arr..sort((a,b) => a-b).filter(n => n > 0)[0]
这是来自QQ邮箱的假期自动回复邮件。 您好,您的邮件我已经收到,我会尽快给您回复,谢谢。