Skip to content

Commit 9f27747

Browse files
committedMay 27, 2020
feat(160)
1 parent af72750 commit 9f27747

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed
 

‎README.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,47 @@
3131

3232
## 今日面试题
3333

34-
159 题:实现 `Promise.retry`,成功后 `resolve` 结果,失败后重试,尝试超过一定次数才真正的 `reject`
34+
160 题:输出以下代码运行结果,为什么?如果希望每隔 1s 输出一个结果,应该如何改造?注意不可改动 square 方法
3535

36+
```js
37+
const list = [1, 2, 3]
38+
const square = num => {
39+
return new Promise((resolve, reject) => {
40+
setTimeout(() => {
41+
resolve(num * num)
42+
}, 1000)
43+
})
44+
}
45+
46+
function test() {
47+
list.forEach(async x=> {
48+
const res = await square(x)
49+
console.log(res)
50+
})
51+
}
52+
test()
53+
```
3654

3755

38-
解析:[第 159 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/387)
56+
57+
解析:[第 160 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/389)
3958

4059
<br/>
4160

4261

4362

4463
## 最近汇总
4564

65+
第 159 题:实现 `Promise.retry`,成功后 `resolve` 结果,失败后重试,尝试超过一定次数才真正的 `reject`
66+
67+
68+
69+
解析:[第 159 题](https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/387)
70+
71+
<br/>
72+
73+
74+
4675
第 158 题:如何模拟实现 Array.prototype.splice
4776

4877

0 commit comments

Comments
 (0)