How to count the number of words in a string with Node.js

1 Answer

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

 



answered Feb 15, 2022 by avibootz
...