const foo = function* () { yield 'a'; yield 'b'; yield 'c'; }; let str = ''; for (const val of foo()) { str = str + val; } console.log(str); // Expected output: "abc"