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

1 Answer

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

 



answered Dec 18, 2023 by avibootz
...