Tell us what’s happening:
It appears i’m solving the problem correctly, but the test report is a failure. I can’t find an issue. I attempted each of the failure cases in the console. The result appears to match the expected result… however, being a console, i could be hiding the issue from myself. i tested typeof, array length, element values also. all seem ok. I’ve included one test case in the js that is reported as failure, but shows as appropriate results in console.
Your code so far
function remove(arr,test) {
let obj = {};
arr.forEach(el=>{
obj[el]=obj[el]?obj[el]+1:1
})
return Object.keys(obj).filter(el=>test(obj[el]))
}
function exists(arr) {
return arr>0
}
function unique(arr) {
return arr===1
}
function sym(args) {
//two dimensional search?
let total = [];
for(let i = 0; i < arguments.length; i++ ) {
total = remove(total.concat(remove(arguments[i], exists)),unique)
}
return total
}
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3], [5, 3, 9, 8], [1]))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/algorithms/find-the-symmetric-difference