MCPcopy Create free account
hub / github.com/Open-Bootcamp/JavaScript-Basico / generaId

Function generaId

sesion-08-funciones/funciones-generadoras.js:1–10  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1function* generaId() {
2 let id = 0;
3 while(true) {
4 id++
5 if (id === 10) {
6 return id
7 }
8 yield id // Esperando hasta que se vuelva a llamar
9 }
10}
11
12const gen = generaId();
13

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected