Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js indexof second occurrence

const string = "XYZ 123 ABC 456 ABC 789 ABC";

function getPosition(string, subString, index) {
  return string.split(subString, index).join(subString).length;
}

console.log(
  getPosition(string, 'ABC', 2) // --> 16
)
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #indexof #occurrence
ADD COMMENT
Topic
Name
9+2 =