Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day388:实现一个sum函数,接收一个arr,累加arr的项,只能使用add方法,该方法接收两个数,模拟异步请求后端返回一个相加后的值? #391

Open
qappleh opened this issue Sep 1, 2021 · 0 comments

Comments

@qappleh
Copy link
Owner

qappleh commented Sep 1, 2021

/*
实现一个sum函数,接收一个arr,累加arr的项,只能使用add方法,该方法接收两个数,模拟异步请求后端返回一个相加后的值
*/

function add(a,b) {
  return Promise.resolve(a+b)
}

function sum(arr) {
  // 思路可以二分,切成两部分beforeSum, afterSum。
}

/*
变种:如果后端设置了并发限制,一次不能请求超过三个,怎么办?
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant