HackerRank solutions - Simple Array Sum

in #hackerrank7 years ago

Doing this so that I can document solutions for HackerRank for myself and discuss runtime complexities with other and try to come up with better solutions.

HackerRank - Simple Array Sum

// solution
function simpleArraySum(n, ar) {
    // Complete this function
    return ar.reduce( function( acc, val ) {
        return acc + val;
    } );
}

I think using the native js reduce function is simple solution without using for loops.

Sort:  

Welcome to the platform, I wish everything work out for you. It’s not easy here but not difficult neither but just ask an extra effort, engagement is the key good luck I’m @goodaytraders Start by following people and they will do the same.

Thanks for the tip.

Coin Marketplace

STEEM 0.25
TRX 0.19
JST 0.035
BTC 92221.99
ETH 3313.28
USDT 1.00
SBD 3.85