How to find the index of the last space in string with JavaScript

1 Answer

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

 



answered Feb 16, 2022 by avibootz

Related questions

1 answer 126 views
1 answer 125 views
1 answer 119 views
1 answer 112 views
1 answer 113 views
1 answer 117 views
...