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)
⬅️ Good point in this weeks' popbitch from Jon Stewart :: Loving the natural movement on this WildCat robot ➡️
Paulʼs blog - I live in Hythe near Folkestone, Kent. Married + father to two, I am a full stack web engineer, + I do js / node, some ruby, python, php etc. I like pubs, parkrun, restaurants, home automation 🤖 + other diy jiggery-pokery, history, genealogy, telly 📺, squirrels, pirates ☠️, lego, + TIME TRAVEL.