DEV Community

Discussion on: Calculate the estimated reading time of an article using JavaScript

Collapse
 
rabiudev profile image
rabiu-dev

I know the split() method splits a string into an array of substrings. But what does the parameter inside this split method do in this code?? split(/\s+/)

Collapse
 
michaelburrows profile image
Michael Burrows

It's a regular expression that splits the string with \s matching single whitespace characters and \s+ matching one or more whitespace characters.

Collapse
 
rabiudev profile image
rabiu-dev

Thank you kind Sir for your explanation...

Collapse
 
wilsonibekason profile image
Wilson Ibekason

nice