I have an array of characters (arr) and a string (J), I wanted to use the array.reduce() method to count the number of characters of the array (arr) present in the string J.
Below is the code which shows how I am using array.reduce() method,
let val = arr.reduce((count , ch) => {
return J.includes(ch) ? count + 1 : count
});
But when I tried with sample value as,
arr = [ 'a', 'A', 'A', 'S', 'S' ];
J = 'aA';
I get the anser as
val = 'a11'