piotrkabacinski
10/9/2018 - 5:08 PM

cq-test-2.js

const containsSum = (a, n) => !!a.find((element, index) => a.slice(++index).find(rest => rest + element === n));
function containsSum(a, n) {
  let state = false;
  
  a.forEach((element, index) => {
    const p = a.slice(++index);
    
    for(let i of p) {
      if(element + i === n) {
        state = true;
        break;
      }
    }
  });
  
  return state;
}

console.log(containsSum([4, 3, 2, 1, 0], 4)); // true