Ad
  • Default User Avatar

    interesting answer, thank you. But it looks mush more complicated than a straightforward two loops with pushing back into vector. Simplier solution is much fatser to read. Is there any performance benefits I simply don't know about?

  • Default User Avatar

    Yes,that's clear now. thanks a lot!)

  • Default User Avatar

    Was interested with your commented solution. After some searching I understood, that I don't understand how could it work in Chrome.
    -In JS 'arguments' is not an Array but Array-like object, it has only 'length' property. To convert easily there is a variant using spread operator '...'.
    -When you use Math functions you can't call them without Math (i.e., Math.max(args)).
    -Math object doesn't have sum() function at all, the best practice I found is using reduce (just as you used above).
    I tried to adjust all that and here is a working modification (but imo it's not so elegant)
    function isTriangle(a,b,c){
    return Math.max(...arguments) < Array.prototype.reduce.call(arguments,(a,b)=> a+b)-Math.max(...arguments);
    }

    PS: never thought about max() function and I like your implementation.

  • Default User Avatar

    Do this works without spliting the string (because the string is inerable by it self) or it is really necessary? If yes, explain, please.