Skip to content

Instantly share code, notes, and snippets.

@robbestad
Created September 28, 2016 06:14
Show Gist options
  • Select an option

  • Save robbestad/8a742dc06dfadb5d1923119ec58a6a49 to your computer and use it in GitHub Desktop.

Select an option

Save robbestad/8a742dc06dfadb5d1923119ec58a6a49 to your computer and use it in GitHub Desktop.
const splitLettersGen = function*(text) {
let i = 0;
const tokens = text.split(" ");
while (i < tokens.length) {
yield tokens[i];
i++;
}
};
const addText = splitLettersGen ("Dette er en test! Dette er nok en test! Jeg tester enda mer.");
setInterval(_ => {
const nextLetter = addText.next();
if(!nextLetter.done){
console.log(nextLetter.value);
}
},30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment