Skip to content

Instantly share code, notes, and snippets.

@sanketmaru
Created August 5, 2015 12:06
Show Gist options
  • Save sanketmaru/9efaae6485d511294dd0 to your computer and use it in GitHub Desktop.
Save sanketmaru/9efaae6485d511294dd0 to your computer and use it in GitHub Desktop.
You want to build a word cloud, an infographic where the size of a word corresponds to how often it appears in the body of text.
var inputString = 'We came, we saw, we conquered...then we ate Bill\'s (Mille-Feuille) cake.'
function(inputString){
var words = [];
for(var i=0;i<inputString.length;i++){
var word = [];
var stringElem = inputString[i];
word.push(stringElem);
if(stringElem === ' ' || stringElem === ',' ){ // marks the end of word
words.push(word);
continue;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment