Tell us what’s happening:
Hi, i don’t understand why my code isn’t working, i checked a lot of times but it doesn’t show anything.
Your code so far
function uniteUnique(arr) {
var newArr = [];
for(var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
console.log(arr[i][j]);
if (newArr.indexOf(arr[i][j]) == -1) {
newArr.push(arr[i][j]);
}
}
}
console.log(newArr);
return newArr;
}
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/83.0.4103.61 Safari/537.36
.
Challenge: Sorted Union
Link to the challenge: