JSFiddle - React, Tailwind, and code Playground

by Lisa French

HTML

<!-- 

String.prototype.count = function(str) {   
    return (this.length - this.replace(new RegExp(str,"g"), '').length) / str.length;
}   

var myStringArray = ["Hello","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
    alert(myStringArray[i]);
    //Do something
}

var str_to_match = "d";
var str_matches = str.match(/d/gi).length;
  alert(num_matches);  // This is number of times that "d" appears in the sentence



-->

JavaScript

var str =...