String manipulation, counting and accounting
const count = (str, subst) => str.match( new RegExp(subst, "g") )?.length || 0;