File tree Expand file tree Collapse file tree 5 files changed +126
-126
lines changed
1-js/06-advanced-functions/08-settimeout-setinterval Expand file tree Collapse file tree 5 files changed +126
-126
lines changed Original file line number Diff line number Diff line change 11
2- Using ` setInterval ` :
2+ Folosind ` setInterval ` :
33
44``` js run
55function printNumbers (from , to ) {
@@ -14,11 +14,11 @@ function printNumbers(from, to) {
1414 }, 1000 );
1515}
1616
17- // usage :
17+ // utilizare :
1818printNumbers (5 , 10 );
1919```
2020
21- Using nested ` setTimeout ` :
21+ Folosind ` setTimeout ` imbricat :
2222
2323
2424``` js run
@@ -34,13 +34,13 @@ function printNumbers(from, to) {
3434 }, 1000 );
3535}
3636
37- // usage :
37+ // utilizare :
3838printNumbers (5 , 10 );
3939```
4040
41- Note that in both solutions, there is an initial delay before the first output. The function is called after ` 1000ms ` the first time .
41+ Observați că în ambele soluții există o întârziere inițială înainte de prima emitere. Funcția este apelată după ` 1000ms ` pentru prima dată .
4242
43- If we also want the function to run immediately, then we can add an additional call on a separate line, like this :
43+ Dacă dorim de asemenea ca funcția să ruleze imediat, atunci putem adăuga un apel suplimentar pe o linie separată, astfel :
4444
4545``` js run
4646function printNumbers (from , to ) {
Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ importance: 5
22
33---
44
5- # Output every second
5+ # Emite în fiecare secundă
66
7- Write a function ` printNumbers(from, to) ` that outputs a number every second, starting from ` from ` and ending with ` to ` .
7+ Scrieți o funcție ` printNumbers(from, to) ` care emite un număr la fiecare secundă, începând de la ` from ` și terminând cu ` to ` .
88
9- Make two variants of the solution .
9+ Creați două variante ale soluției .
1010
11- 1 . Using ` setInterval ` .
12- 2 . Using nested ` setTimeout ` .
11+ 1 . Folosind ` setInterval ` .
12+ 2 . Folosind ` setTimeout ` imbricat .
Original file line number Diff line number Diff line change 11
2- Any ` setTimeout ` will run only after the current code has finished .
2+ Orice ` setTimeout ` va rula numai după ce codul curent s-a terminat .
33
4- The ` i ` will be the last one : ` 100000000 ` .
4+ ` i ` va fi ultimul : ` 100000000 ` .
55
66``` js run
77let i = 0 ;
88
99setTimeout (() => alert (i), 100 ); // 100000000
1010
11- // assume that the time to execute this function is >100ms
11+ // să presupunem că timpul de execuție a acestei funcții este >100ms
1212for (let j = 0 ; j < 100000000 ; j++ ) {
1313 i++ ;
1414}
Original file line number Diff line number Diff line change @@ -2,25 +2,25 @@ importance: 5
22
33---
44
5- # What will setTimeout show ?
5+ # Ce va arăta setTimeout ?
66
7- In the code below there's a ` setTimeout ` call scheduled, then a heavy calculation is run, that takes more than 100ms to finish .
7+ În codul de mai jos este planificat un apel ` setTimeout ` , apoi se rulează un calcul intensiv, care durează mai mult de 100ms pentru a se termina .
88
9- When will the scheduled function run ?
9+ Când se va executa funcția planificată ?
1010
11- 1 . After the loop .
12- 2 . Before the loop .
13- 3 . In the beginning of the loop .
11+ 1 . După buclă .
12+ 2 . Înainte de buclă .
13+ 3 . La începutul buclei .
1414
1515
16- What is ` alert ` going to show ?
16+ Ce va arăta ` alert ` ?
1717
1818``` js
1919let i = 0 ;
2020
2121setTimeout (() => alert (i), 100 ); // ?
2222
23- // assume that the time to execute this function is >100ms
23+ // să presupunem că timpul de execuție a acestei funcții este >100ms
2424for (let j = 0 ; j < 100000000 ; j++ ) {
2525 i++ ;
2626}
You can’t perform that action at this time.
0 commit comments