Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/Loops-Do-while/JavaScript/loops-do-while-8.js
Normal file
20
Task/Loops-Do-while/JavaScript/loops-do-while-8.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// generator with the do while loop
|
||||
function* getValue(stop) {
|
||||
var i = 0;
|
||||
do {
|
||||
yield ++i;
|
||||
} while (i % stop != 0);
|
||||
}
|
||||
|
||||
// function to print the value and invoke next
|
||||
function printVal(g, v) {
|
||||
if (!v.done) {
|
||||
console.log(v.value);
|
||||
setImmediate(printVal, g, g.next());
|
||||
}
|
||||
}
|
||||
|
||||
(() => {
|
||||
var gen = getValue(6);
|
||||
printVal(gen, gen.next());
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue