How to print all strings from an array that contain a given substring in TypeScript

1 Answer

0 votes
const words: string[] = ['property', 'typescript', 'multiprocessing', 'c++', 'java', "weatherproofing"]
  
const result: string[] = words.filter(word => word.includes('pro'));
  
result.forEach(w => console.log(w))
  
  
  
/*
run:
  
property
multiprocessing
weatherproofing
  
*/

 



answered Dec 18, 2023 by avibootz
...