How to print all strings from an array that ends with a given substring in Node.js

1 Answer

0 votes
const words = ['mining', 'node.js', 'sing', 'c', 'java', "programming"]
 
const result = words.filter(w => w.endsWith('ing'))
 
result.forEach(w => console.log(w))
 

 
 
/*
run:
 
mining
sing
programming
 
*/

 



answered Dec 18, 2023 by avibootz
...