Created
June 5, 2016 03:28
-
-
Save anonymous/a7b8c5e0568bb9087d6dc703fbbfbe08 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