@@ -65,7 +65,7 @@ for (let i = num1; i <= num2; i++) {
6565
6666``` js
6767const num1 = 1 , num2 = 10 ;
68- + function displayWithDelay (i ){
68+ function displayWithDelay (i ){
6969 console .log (i);
7070 if (i !== num2)
7171 setTimeout (displayWithDelay, 1000 , ++ i);
@@ -113,7 +113,9 @@ for (var i = num1; i >= num2; i--) {
113113var num1 = 10 , num2 = 1 ;
114114for (var i = num1; i >= num2; i-- ) {
115115 (function (i ) {
116- setTimeout (function () { console .log (i); }, (num1 - i) * 1000 );
116+ setTimeout (function () {
117+ console .log (i);
118+ }, (num1 - i) * 1000 );
117119 })(i);
118120}
119121```
@@ -250,8 +252,8 @@ function asyncParallel(asyncFuncArr, callback) {
250252 const resultArr = new Array (asyncFuncArr .length );
251253 let resultCounter = 0 ;
252254
253- asyncFuncArr .forEach ((async , index ) => {
254- async (value => {
255+ asyncFuncArr .forEach ((asyncFun , index ) => {
256+ asyncFun (value => {
255257 resultArr[index] = value;
256258 resultCounter++ ;
257259 if (resultCounter >= asyncFuncArr .length ) {
@@ -321,14 +323,13 @@ If `then` method has a return statement which is a promise then it will be consi
321323- Async function with ` await ` for each promise can be used to execute in sequence
322324
323325``` js
324- + async function executor (){
325- try {
326+ async function executor (){
327+ try {
326328 await asyncFunc1 ();
327329 await asyncFunc2 ();
328330 await asyncFunc3 ();
329331 console .log (' All succeeded' );
330- }
331- catch (){
332+ } catch (){
332333 console .log (" Error occured);
333334 }
334335}();
@@ -379,7 +380,7 @@ async1()
379380- `catch` block for each asynchronous function can be used to catch errors and continue with next execution which will not propagate failures
380381
381382```js
382- + (async function executor() {
383+ (async function executor() {
383384 try {
384385 await asyncFunc1();
385386 console.log('Async1 success');
0 commit comments