// Corrected solution
const func = (arr, sum) =>
.map((x, i) => [x, i])
.map(([x1, i1], _, a) => [i1, a.findIndex(([x2, i2]) => i1 !== i2 && x1 + x2 === sum)])
.find(([i1, i2]) => i2 !== -1);
I can't believe thwre are people saying JS is beautiful
Doesn't this return the values that sum up to the target value and not their indices in the array?
It did. I've now corrected it, I hope.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.