Count string Replaces

by greatCar

JavaScript

var string = "This is this is";
var number = 0;
var x = string.replace(/is/g, function() {
  number++;
  return "as";
});

alert (x);
alert(number);