Find words and count them in a paragraph

Find words and count them in a paragraph
0

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

console.log(result);
var resultCount=0;

if(Array.isArray(result)){
for(var i=0;i<result.length;i++){
   resultCount++;
}
console.log("result count = "+resultCount);
}
//result 
//Free,free,free,free
//result count = 4

#2

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.


#3

Thanks bro
there have many ways to do it .