How to get the index of the last occurrence of a word in string in TypeScript

1 Answer

0 votes
const str = "typescript c++ php typescript c# typescript python";
  
const wordtofind = "typescript";

const index = str.lastIndexOf(wordtofind);
  
console.log(index);
 
  
  
  
  
/*
  
run:
  
33
  
*/

 



answered Jun 7, 2022 by avibootz
...