string count method in javascript code example Example: js string count (mainStr.split("str").length - 1) //4