-
-
Save shtakai/7f1155be237aa326ec1e3d0ea55bbc77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var words = ["fun", "exciting", "about not giving up", "being helpful", "being open", "what I learned at CodingDojo!"], | |
el = document.getElementById('magic'), | |
word_counter = 0, | |
character_counter = 0; | |
function updateText() | |
{ | |
var next_character = words[word_counter][character_counter++]; | |
if(next_character == ' '){ | |
next_character = ' '; | |
} | |
el.innerHTML = el.innerHTML+next_character; | |
if(character_counter == words[word_counter].length + 1) | |
{ | |
word_counter++; //choose a different word | |
character_counter = 0; //start over with the first character of the word | |
el.innerHTML = ''; //set the html to be blank | |
//if we're displaying the last word, go back to the first word | |
if(word_counter == words.length) | |
word_counter = 0; | |
} | |
} | |
setInterval(updateText,250); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment