Skip to content

Commit 413b161

Browse files
committed
Fix examples
1 parent 9d0693a commit 413b161

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

JavaScript/b-yield.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

3-
function* counter(begin, end, delta) {
3+
function* counter(begin, end, delta = 1) {
44
let value = begin;
55
while (end > value) {
66
value += delta;
7+
if (value > end) return;
78
yield value;
89
}
910
}

JavaScript/c-return.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function* ids(...args) {
44
let i = 0;
55
while (args.length > i) {
66
const id = args[i++];
7-
if (id === undefined) return -1;
7+
if (id === undefined) return;
88
yield id;
99
}
1010
}

JavaScript/d-for-of.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function* ids(...args) {
44
let i = 0;
55
while (args.length > i) {
66
const id = args[i++];
7-
if (id === undefined) return -1;
7+
if (id === undefined) return;
88
yield id;
99
}
1010
}

JavaScript/e-spread.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ function* ids(...args) {
44
let i = 0;
55
while (args.length > i) {
66
const id = args[i++];
7-
if (id === undefined) return -1;
7+
if (id === undefined) return;
88
yield id;
99
}
1010
}
1111

1212
const id = ids(1011, 1078, 1292, 1731, undefined, 1501, 1550);
13-
console.log([...id]);
13+
console.log(...id);

0 commit comments

Comments
 (0)