Find words and count them in a paragraph

let paragraph = "Hello Freecodecamp student's , free , freecodecamp , free learning";
let word = /free/ig; 
let result = paragraph.match(word);

var resultCount=0;

for(var i=0;i<result.length;i++){
console.log("result count = "+resultCount);
//result count = 4

Maybe you can use String.split(" ") to split the paragraph into an array of words. Then you can use Array.length to get the length of the array.

1 Like

Thanks bro
there have many ways to do it .