This tested our brains 1 at work today. Here is my solution to the last one:
function arraySum( i ) {
return i.reduce( function ( a, b ) {
if ( b instanceof Array ) b = arraySum( b );
if ( typeof b !== 'number' ) return a;
return a + b;
}, 0 );
}
I was dead slow as I kept insisting on using reduce, and forgetting what the params are for it, but I got there in 16 mins.
(and I took a phone call in the middle of that)
javascript: Programming language of the web, mostly how I make my living.
⬅️ Good point in this weeks' popbitch from Jon Stewart :: Loving the natural movement on this WildCat robot ➡️
Paul Clarkeʼs weblog - I live in Hythe near Folkestone, Kent. Wed to Clare + dad to 2, I am a full-stack web engineer, and I do javascript / nodejs, some ruby, python, php ect ect. I like pubbing, parkrun, eating, home-automation and other diy jiggery-pokery, history, genealogy, Television, squirrels, pirates, lego, and time travel.