Hey there!
I solved this problem finally, but I just wanted to know a few things… (removed some questions because they turned out to be user error :P)
- Wouldn’t this example be a more ‘basic’ solution for ‘get a hint’?
- Any advice on better formatting is welcomed. Thank you!!
this site is very empowering so far.
Your code so far
function diffArray(arr1, arr2) {
let concatArr = arr1.concat(arr2);
concatArr.sort((a,b) => a > b);
let finalArr = [];
for(let i = 0; i < concatArr.length;i++) {
let splitArr = [...concatArr];
splitArr.splice(i,1);
if(splitArr.indexOf(concatArr[i]) < 0) {
finalArr.push(concatArr[i]);
}
}
return finalArr;
}
console.log(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays