Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript word 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
Source by scrimba.com #
 
PREVIOUS NEXT
Tagged: #javascript #word #count
ADD COMMENT
Topic
Name
6+5 =