I have the following Arrays:
this.originalSelectedRows = [1,2,3,4,5];
this.selectedRows = [3,4,5,6,7,8];
I want to know the following:
How many numbers are in this.originalSelectedRows
, but not in this.selectedRows
Which in this case would be 2:
1 and 2
and how many numbers are in this.selectedRows
, but not this.originalSelectedRows
Which in this case would be 3:
6, 7 and 8
I have the following, which works fine:
let isOnListCount = 0;
let isNotOnListCount = 0
this.selectedRows.map((row) => {
const isSelected = this.originalSelectedRows.filter(x => x === row);
if(isSelected.length > 0)
isOnListCount++;
else
isNotOnListCount++;
});
But I want to know if this can be achieved in a neater fashion usng some of ES6's new features, or original JS