How to find the index of the last space in string with Node.js

1 Answer

0 votes
const str = "javascript php c typescript node.js c++ c# python";
  
const last_index = str.lastIndexOf(' ');
   
console.log(last_index);
    
       
        
        
/*
run:
        
42
        
*/

 



answered Feb 17, 2022 by avibootz
...