Tell us what’s happening:
I’ve solved this challenge and input it into the fcc interface. The results displayed (console.log) match those outlined on the challenge page, but every single test reports failure when I check them.
I’ve been working in PythonTutor to see it run live and I get the desired results there as well.
Any idea why this isn’t passing?
Your code so far
// convert object to array
args = Array.prototype.slice.call(arguments);
// check that item in position doesn't = item in position immediately before it, returns only unique values
function single(a) {
return a.sort().filter(function(el, pos, ary) {
return !pos || el != ary[pos-1];
});
}
function duplicates(b) {
b.forEach(function(el) {
return b.filter(function(el, pos, ary) {
var firstPos = b.indexOf(el);
// remove both item & value in position that matched
if (firstPos !== pos) {
b.splice(firstPos, 1);
b.splice(pos-1, 1);
}
});
});
}
var arr1 = arguments[0];
for (var a = 1; a < args.length; a++) {
arr1 = single(arr1);
var arr2 = arguments[a];
arr2 = single(arr2);
var merged = arr1.concat(arr2);
duplicates(merged);
arr1 = merged;
}
var sorted = arr1.sort();
console.log(sorted);
return sorted;
}
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:
Your Browser User Agent is: Chrome Version 63.0.3239.84 (Official Build) (64-bit)
.
Link to the challenge:
https://www.freecodecamp.org/challenges/symmetric-difference