How to count spaces in a string with TypeScript

1 Answer

0 votes
const str = "typescript    php  c   c++";
 
const len = str.split(" ").length - 1

console.log(len); 
  
  
   
     
     
/*
run:
     
9
     
*/

 



answered Feb 15, 2022 by avibootz
...