You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/12-generators-iterators/1-generators/article.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -347,16 +347,16 @@ generator.next(4); // --> pass the result into the generator
347
347
2. Then, as shown at the picture above, the result of `yield` gets into the `question` variable in the calling code.
348
348
3. On `generator.next(4)`, the generator resumes, and `4` gets in as the result: `let result = 4`.
349
349
350
-
Please note, the outer code does not have to immediately call`next(4)`. It may take time to calculate the value. That's not a problem: the generator will resume when the call is made.
350
+
Please note, the outer code does not have to immediately call`next(4)`. It may take time. That's not a problem: the generator will wait.
351
351
352
-
This is also a valid code:
352
+
For instance:
353
353
354
354
```js
355
355
// resume the generator after some time
356
356
setTimeout(() =>generator.next(4), 1000);
357
357
```
358
358
359
-
As we can see, unlike regular functions, generators and the calling code can exchange results by passing values in `next/yield`.
359
+
As we can see, unlike regular functions, a generator and the calling code can exchange results by passing values in `next/yield`.
360
360
361
361
To make things more obvious, here's another example, with more calls:
0 commit comments