文章 评论 浏览 27
function add(...a) { let sum = a.reduce((p, n) => p + n); function next(...b) { let _sum = b.reduce((p, n) => p + n); sum = sum + _sum; return next; } next.toString = function () { return sum; }; return next; }
Promise.retry = function(fn, num){ return new Promise(function(resolve, reject){ while(num>0){ try{ const res = await fn resolve(res) num = 0 } catch(e){ if(!num) reject(e) } num -- } }) }
文章 0 评论 0
接受
第 84 题:请实现一个 add 函数,满足以下功能