I want to get the exact difference between two string arrays.
const array1 = [\'T\',\'E\',\'A\',\'P\',\'A\',\'P\',\'E\',\'R\'];
const array2 = [\'T\',\'A\',\
You could remove elements from allowed
based on the input
array:
const allowed = ['T','E','A','P','A','P','E','R'];
const input = ['T','A','P'];
for(const char of input) {
const pos = allowed.indexOf(char);
if(pos === -1) {
// char doesnt exist?
} else {
allowed.splice(pos, 1);
}
}
Then allowed
will be your expected result at the end.