Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript paragraph count

const string = "Hello world"

const charCount = string.length //11
const charCountWithoutWhitespace = string.replace(/s/g, '').length //10
const wordCount = string.split(/s+/).length //2
const paragraphCount = string.replace(/
$/gm, '').split(/
/).length //1
 
PREVIOUS NEXT
Tagged: #javascript #paragraph #count
ADD COMMENT
Topic
Name
8+9 =