Hi
I started this problem by wanting to unite all the elements from the arrays into one array and then play with that array to find the solution.
I tried to create this using a for look with the final parameter equal to (arguments.length - 1) because the function is using concat on (arr[i+1]). If I use i++ it would loop once too often
My console.log isn’t outputting a result so my code is wrong!
Is there a way to use a for loop like this where it keeps looping relative to the arguments length?
Your code so far
function uniteUnique(arr) {
let monsterArr = function(arr){
for (var i = 0; i < arguments.length; i = arguments.length - 1){
arr[i].concat(arr[i+1])
}
return monsterArr;
}
}
console.log(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sorted-union