For example: if arr contains [4, 6, 23, 10, 1, 3] the output should return true because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative numbers.
My Attempt
Uses a recursive method to find all permutations of the arr and adds elements up to see if they add up to array max. The function checks all permutations correctly but does not return correct boolean.
function arrayAddition(arr) {
var arrMax = arr.sort(function(a, b) {
return a - b;
}).pop();
function recArrAdd(sub, arr) {
if (arr.length > 0) {
var arrSum = sub.concat(arr[0]).reduce(function(prev, curr) {
return prev + curr;
});
if (arrSum === arrMax) return true;
recArrAdd(sub.concat(arr[0]), arr.slice(1));
recArrAdd(sub, arr.slice(1));
}
return false;
}
return recArrAdd([], arr);
}
console.log(arrayAddition([1, 2, 3]));

.reduce()call in the function posted!