How to find words in a string which are greater than given length with JavaScript

1 Answer

0 votes
const str = "JavaScript is a programming language that is one of the core technologies of the World Wide Web";
const len = 6;

let array = str.split(" ");

let words = [];

for (const s of array) {
    if (s.length > len) {
        words.push(s);
    }
}

console.log(words);




/*
run:

[ 'JavaScript', 'programming', 'language', 'technologies' ]

*/

 



answered Nov 29, 2023 by avibootz
...