How to count the number of words in a string with TypeScript

1 Answer

0 votes
const str = "typescript php c c++";
 
const len = str.split(" ").length;
 
console.log(len); 
 
 
   
     
     
/*
run:
     
4
     
*/

 



answered Feb 15, 2022 by avibootz
...