Solución

@fernando_her85
·hace 5dTypeScript
solution.tsTypeScript
function* nextLetter(word: string) {
  for(let letter of word) {
    yield letter;
  }
}

export function intercalateChars(first: string, second: string) {
  
  const it1 = nextLetter(first);
  const it2 = nextLetter(second);
  let output = ''

  while(true) {
    const { value: v1, done: d1 } = it1.next();
    const { value: v2, done: d2 } = it2.next();

    if( d1 && d2) break;
    if ( !d1 )  output += v1;
    if ( !d2 )  output += v2;
  }

  return output;
}
0respuestas
Respuestas
0

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.
Markdown