Yes I completely understand the solution using
every(), but I would really like to understand the other one. Where is the difference in the ()s?
let z = y.filter(arr => x
.map(n => arr.includes(n) && arr + arr === 7))
.reduce((a, b) => a && b);
Your ()s are not identical to the solution. I can only say that so many ways. Look at where every single pair opens and closes in the code I posted directly from the solutions page.
// filter the collection
return collection.filter(obj => souceKeys
.map(key => obj.hasOwnProperty(key) && obj[key] === source[key])
.reduce((a, b) => a && b)
); // <---- LOOK RIGHT HERE
Start counting left and right parens I’ll ask again, do you want to reduce the results of the map, or the results of the filter?
I finally got it, so it was all about the () placement.