From 512731e95570e53e00b6ccea4f565cb265956bec Mon Sep 17 00:00:00 2001 From: jiuzhouA Date: Wed, 31 May 2023 11:58:56 +0800 Subject: [PATCH] docs: Fixed the issue where the function returned an empty value, corrected the field name, and optimized the wrapping of promises. --- .../promise/promise.md | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/docs/standard-built-in-objects/control-abstraction-objects/promise/promise.md b/docs/standard-built-in-objects/control-abstraction-objects/promise/promise.md index 3b06fa6a2..e39d6e1ce 100644 --- a/docs/standard-built-in-objects/control-abstraction-objects/promise/promise.md +++ b/docs/standard-built-in-objects/control-abstraction-objects/promise/promise.md @@ -173,21 +173,18 @@ execute([Task('A'), Task('B'), Task('C', false), Task('D')]).then((resultList) = ```js function execute(tasks) { - return; - task.reduce( + return tasks.reduce( (previousPromise, currentPromise) => previousPromise.then((resultList) => { - return new Promise((resolve) => { - currentPromise() - .then((result) => { - resolve(resultList.concat(result)); - }) - .catch(() => { - resolve(resultList.concat(null)); - }); - }); + return currentPromise() + .then((result) => { + return resultList.concat(result); + }) + .catch(() => { + return resultList.concat(null); + }); }), - [] + Promise.resolve([]) ); } ```