Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #count #punctuation #string #js
ADD COMMENT
Topic
Name
6+3 =