Skip to content

Instantly share code, notes, and snippets.

@tarzak
Created November 2, 2015 09:00
Show Gist options
  • Save tarzak/32997f72379b82d5f21f to your computer and use it in GitHub Desktop.
Save tarzak/32997f72379b82d5f21f to your computer and use it in GitHub Desktop.
function square(a) {
return a*a;
}
function squareMaxElements (a,b,c) {
var min = Math.min(a,b,c)
, arr = [a,b,c]
;
return arr = arr.filter(function (element) {
return element !== min
}).reduce(function(previous, next) {
return square(previous) + square(next)
});
}
@coderaiser
Copy link

Be liberal in what you accept, and conservative in what you send
or
Expect the worst. Behave your best.

Coul you provide more bullet proof solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment