Tell us what’s happening:
Describe your issue in detail here.
I wanted to solve this challenge by combining all the arguments into an array and then removing the duplicate elements of the array . I know my code is not right but this is what I typed as per my knowledge. Can anyone guide me ?
Your code so far
function uniteUnique(arr) {
let newArr = [arguments];
for (let i = 0; i < newArr.length; i++){
for (let j = 0; j < newArr.length; j++){
if(newArr[i] === newArr[j]){
delete newArr[j];
}
}
}
return newArr;
}
console.log(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]));
}
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/114.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Sorted Union
thanks a lot for this tip … now how can I delete the duplicates ? I guess Another way could be pushing the does not include elements in another array but I want to delete the duplicates from the newArr.
function uniteUnique(arr) {
let newArr = [...arguments].flat();
console.log(newArr);
for (let i = 0; i < newArr.length; i++){
for (let j = 0; j < newArr[i].length; j++){
if(newArr[i] === newArr[i][j]){
delete newArr[j];
}
}
}
return newArr;
}
console.log(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]));
thank You Wong and Jeremy for all your help I completed the challenge . You both have been a great help for me since quite a time. See You at next Doubt .