Hi!
First, I want to say that the entire FFC is amazing and you guys should all go to tech heaven for supporting this outstading organaization!
second:
I’m at the “Intermediate Algorithm Scripting: Diff Two Arrays”, when I need to return the symmetric difference of the two arrays. The code works, but the FCC checker says it doesnt work in certain exrecises:
function diffArray(arr1, arr2) {
let arr1Obj = {};
let arr2Obj = {};
let unique = [];
for (let i = 0; i < arr1.length; i++) {
arr1Obj[arr1[i]] = arr1Obj[arr1[i]] ? arr1Obj[arr1[i]] +=1 : (arr1Obj[arr1[i]] = 1)
}
for (let j = 0; j < arr2.length; j++) {
arr2Obj[arr2[j]] = arr2Obj[arr2[j]] ? arr2Obj[arr2[j]] +=1 : (arr2Obj[arr2[j]] = 1)
}
for (let key in arr1Obj) {
if (!arr2Obj.hasOwnProperty(key)){
unique.push(key)
}}
for (let key2 in arr2Obj) {
if (!arr1Obj.hasOwnProperty(key2)){
unique.push(key2)
}}
return unique
}
*** diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]); should retrun 4 - - IT DOES
*** [1, "calf", 3, "piglet"], [1, "calf", 3, 4] should return ["piglet", 4] - - IT DOES
*** [1, "calf", 3, "piglet"], [7, "filly"] should return [1, "calf", 3, "piglet", 7, "filly"] - - IT DOES
The rest works fine.
Thank you very much for your help!
