Answers for "count no of punctuation in string in js"

0

count no of punctuation in string in js

function countPunctuation(str) {
   const punct = "!,\;\.-?";
   let count = 0;
   for(let i = 0; i < str.length; i++){
      if(!punct.includes(str[i])){
         continue;
      };
      count++;
   };
   return count;
}
Posted by: Guest on March-22-2021

Code answers related to "count no of punctuation in string in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language