function substrCount( str, x ) { let count = -1, pos = 0; do { pos = str.indexOf( x, pos ) + 1; count++; } while( pos > 0 ); return count; }
↧
Answer by mendezcode for How to count string occurrence in string?
↧