How to find the index of the last occurrence of a character in a string with JavaScript

1 Answer

0 votes
const str = 'javascript c++ typescript node.js';

const index = str.lastIndexOf('t');

console.log(index);




/*
run:
 
24
  
*/

 



answered Jun 7, 2022 by avibootz
...