Created
January 25, 2014 22:14
-
-
Save slopeofhope81/8624438 to your computer and use it in GitHub Desktop.
my first extensive function/ I need to find a way to refactor...and encapsulate
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 mailArchive = retrieveMails(); | |
var livingCats = {"Spot": true}; | |
for (var mail = 0; mail < mailArchive.length; mail++) | |
var paragraphs = mailArchive[mail].split("\n"); //split the paragraphs | |
for (var paragraph = 0; paragraph < paragraph.length; paragraph++){ | |
if (startsWith(paragraph, "born")){ | |
var names = catNames(paragraphs[paragraph]) | |
for (var name = 0; name < names.length; names++) | |
livingCats[names[name]] = true; | |
} | |
else if(startsWith(paragraph,"died")){ | |
var names = catNames(paragraphs[paragraph]) | |
for (var name = 0; name < names.length; names++) | |
delete livingCats[Names[name]]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment