Have tried this a few different ways and I've run into issues each time.
My initial approach:
function solve(a,b) {
var re = new RegExp(b,"g");
var res = a.match(re);
console.log(res);
}
solve("zaz","zazapulz") //returns null
And this approach as well:
function solve(a,b) {
String.prototype.count=function(c) { 
  var result = 0, i = 0;
  for(i;i<this.length;i++)if(this[i]==c)result++;
  return result;
};
console.log(a.count(b)); 
}
solve("zaz","zazapulz") //returns 0
 
     
     
    