I am doing this challenge which tells you to only gives out the elements that do not co-exist in two given arrays.
I am trying to solve this problem using these steps/logics.
-
concat
two array into one arraynewArray
- filter out all the array elements as long as it appeared more than once.
I tried out this array and find that if you have duplicates inside your array, the position of the element will not be updated once it appeared inside an array. See [3] is both position 2 from the console.
so here is my “solution” with some pseudocode in it
var arr = [“hello”,“world”,3,4,5,62,3,12];
for(let i = 0; i < arr.length; i++){
if(/arr.indexOf(arr[i]) appeared more than once/){
arr.splice(i,1);
}
}
console.log(arr);
how do I convert that pseudocode to javascipt?
am I overly complicating things here?