const solution = (string, target) =>
string.split('').filter(char => char == target).length;
const result = solution('COMPUTERPROGRAMMING', 'R');
console.log(result);
const solution = (string, target) => {
const regex = new RegExp(`${target}`, 'g');
return string.match(regex).length;
};
const result = solution('COMPUTERPROGRAMMING', 'R');
console.log(result);