How to split string into array of words in TypeScript

1 Answer

0 votes
let str = "James John William";
  
const arr = str.split(" "); 
 
arr.forEach(function(word) {
  console.log(word);
});
 
 
 
 
/*
run:
 
"James"
"John"
"William"
 
*/

 



answered Nov 24, 2021 by avibootz

Related questions

...