Tell us what’s happening:
I’m not sure why this isn’t working. I put the same code in vscode and it returns the right values. How come its not working here. Is there syntax missing or is my logic wrong.
Your code so far
function pairwise(arr, target) {
const pairs = [];
if (arr.length == 0) {
return arr;
}
for (i = 0; i < arr.length; i++) {
for (j = i + 1; j < arr.length; j++) {
if (arr[i] + arr[j] == target) {
pairs.push(i, j);
}
}
};
let sum = pairs.reduce((acc, curr) => {
return acc + curr;
}, 0);
return sum;
}
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Daily Coding Challenge - Pairwise
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-12-19