javascript string search second occurrence

Solutions on MaxInterview for javascript string search second occurrence by the best coders in the world

showing results for - "javascript string search second occurrence"
María Alejandra
28 May 2020
1const string = "XYZ 123 ABC 456 ABC 789 ABC";
2
3function getPosition(string, subString, index) {
4  return string.split(subString, index).join(subString).length;
5}
6
7console.log(
8  getPosition(string, 'ABC', 2) // --> 16
9)