by kirse · 13y ago · 0 comments
n===+n && n===(n|0)
Wish I could see my answers after the fact though!Edit: Read the initial requirements of the puzzle, it says sum all the integers, not all the numbers. People using (typeof i[x] == 'number') just got lucky because the test-cases didn't exercise the full requirements of the puzzle ;)
// i will be an array, containing integers and/or arrays like itself.
// Sum all the integers you find, anywhere in the nest of arrays. sum += i[p];
}else if(typeof i[p] === typeof [3]){//it's an array recursion(i[p]);
}pretty simple no?
I dread to think what obscure code I've left behind.
You should learn a little more about JS before you call this simple.
n % 1 == 0It didn't actually require differentiating between integers and floats, just numbers and other types.
Normally javascript function inputs aren't this messy.