Created
January 23, 2018 02:33
-
-
Save vapidbabble/81badfa93531383b05ffa1f89ab89854 to your computer and use it in GitHub Desktop.
Class 4 lesson 4 part bonus bonus
This file contains hidden or 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 sentenceBio = "I spent my caterpillar days in marketing, my cocoon days at Nashville Software School, and my butterfly days as a developer." // enter the full string here (no need to seperate words with commas) | |
function overlyExcited (theWordArray) { | |
var words = theWordArray.split(" "); // splits sentence into an array | |
var container = ""; //holds the sentence. Initialized to no space to start the sentence | |
var excited = "!"; //holds the ! | |
for(var i = 0; i < words.length; i++){ | |
if((i+1) %3 == 0){ //check to see if the word's arra number has a remainder of 0 after being divided by 3 | |
console.log(container + words[i] + excited); //log to console whats in the container + !s + the next word in the array | |
container += words[i] + excited + " "; //creates/stores a new sentence in the container with the newly added word | |
excited = "!" + excited; //adds an extra exclimation mark each time it runs this ! !! !!! !!!!.... | |
} else { | |
console.log(container + words[i]); // this runs when there is no need to add another exclimation point | |
container += words[i] + " "; //creates/stores a new sentence in the container with the newly added word | |
} | |
} | |
} | |
overlyExcited(sentenceBio); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment