I have a javascript file and I would like to know how to count the number of hindi words in my textarea using javascript. it counts the number of english words fine but not with hindi words. Can someone help me please?
javascript code:
function getDifficultSentences(p) {
let sentences = getSentenceFromParagraph(p);
data.sentences += sentences.length;
let hardOrNot = sentences.map(sent => {
let cleanSentence = sent.replace(/[^a-z|]/gi, "") + "|";
let words = cleanSentence.split("").length; // the line where the I used for counting the words
document.getElementById("nice").innerHTML= words.toString();
let letters = cleanSentence.split("").join("").length;
data.words += words;
sent = getAdverbs(sent);
sent = getComplex(sent);
sent = getPassive(sent);
sent = getQualifier(sent);
sent = countWords(sent);
//sent = getComplexDigit(sent);
let level = calculateLevel(letters, words, 1);
if (words < 14) {
return sent;
} else if (words >= 14 && words< 25) {
data.hardSentences += 1;
return `<span class="hardSentence">${sent}</span>`;
} else if (words >= 30) {
data.veryHardSentences += 1;
return `<span class="veryHardSentence">${sent}</span>`;
} else {
return sent;
}
});
return hardOrNot.join("");
}