Skip to content

Commit 4bea0a5

Browse files
committed
Assalomu alaykum
uz.javascript.info/1-js/06-advanced-functions/08-settimeout-setinterval/3-rewrite-settimeout/solution.md file qo'shdim va kichik tarjimani amalga oshirdim faqat javascript.info saytidagi original Taskni topolmadim shuning uchun javob to'griligiga ishinchim komil emas tekshirib qabul qiling
1 parent a9d99b5 commit 4bea0a5

File tree

1 file changed

+24
-0
lines changed
  • 1-js/06-advanced-functions/08-settimeout-setinterval/3-rewrite-settimeout

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using `setInterval`
2+
3+
```js run
4+
let i = 0;
5+
6+
let start = Date.now();
7+
8+
function count() {
9+
10+
if (i == 1000000000) {
11+
alert("Done in " + (Date.now() - start) + 'ms');
12+
} else {
13+
setTimeout(() => { clearInterval(count) }, 5000);
14+
}
15+
16+
// a piece of heavy job
17+
for(let j = 0; j < 1000000; j++) {
18+
i++;
19+
}
20+
21+
}
22+
23+
count();
24+
```

0 commit comments

Comments
 (0)