I have 2 array as shown below:
arr1 = [a,b,c,a,c,b,a]
arr2 = [b,b,a,a,a,b,c]
I am checking the number of occurrence of each item in both arrays are same
for e.g. a is count in arr1 and arr2 is 3. like wise want to check for rest of the items if it is same the continue or break the loop
for(let i=0; i < this.arr1.length; i++){
for(let j=0; j < this.arr2.length; j++){
if(this.arr1[i] === this.arr2[j]){
let count1 = this.arr1.filter((t) => {
return t == this.arr1[i];
});
let count2 = this.arr2.filter((e) => {
return e == this.arr2[j];
});
if(count1.length !== count2.length){
// break the loops and return false
}
}
}
}
Above code is not working correctly. where am i doing wrong.