Skip to content

Commit ac881b3

Browse files
authored
Merge pull request #32 from duanjiuzhou/patch-1
docs: Fixed the issue where the function returned an empty value, cor…
2 parents fdae8b8 + 512731e commit ac881b3

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

  • docs/standard-built-in-objects/control-abstraction-objects/promise

docs/standard-built-in-objects/control-abstraction-objects/promise/promise.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,18 @@ execute([Task('A'), Task('B'), Task('C', false), Task('D')]).then((resultList) =
173173

174174
```js
175175
function execute(tasks) {
176-
return;
177-
task.reduce(
176+
return tasks.reduce(
178177
(previousPromise, currentPromise) =>
179178
previousPromise.then((resultList) => {
180-
return new Promise((resolve) => {
181-
currentPromise()
182-
.then((result) => {
183-
resolve(resultList.concat(result));
184-
})
185-
.catch(() => {
186-
resolve(resultList.concat(null));
187-
});
188-
});
179+
return currentPromise()
180+
.then((result) => {
181+
return resultList.concat(result);
182+
})
183+
.catch(() => {
184+
return resultList.concat(null);
185+
});
189186
}),
190-
[]
187+
Promise.resolve([])
191188
);
192189
}
193190
```

0 commit comments

Comments
 (0)