Skip to content

Instantly share code, notes, and snippets.

@yegnold
Created November 8, 2013 13:54
Show Gist options
  • Save yegnold/7371340 to your computer and use it in GitHub Desktop.
Save yegnold/7371340 to your computer and use it in GitHub Desktop.
For cole henley, not tested, probably errors all over the place, but this was my general approach
function add_all_integers(i) {
// i is an array that might contain arrrays, integers, strings, add all integers within it
var total = 0;
function add_iterate(item) {
for(var counter=0;counter<item.length;counter++) {
if(typeof item[counter] == 'object') {
add_iterate(item[counter]);
} else if(typeof item[counter] == 'number') {
total += item[counter];
}
}
}
add_iterate(i);
return total;
}
@yegnold
Copy link
Author

yegnold commented Nov 8, 2013

OK, surprisingly, running it in the console seems to suggest it is syntactically and functionally correct, wow, that's gotta be the first time ever for writing javascript - haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment