Skip to content

Splitting on spaces gives an inflated estimation of time to read #2

@xiaohutai

Description

@xiaohutai

On https://github.com/heyimjuani/minRead/blob/master/minRead.js#L28, use

return Math.ceil(text.split(/\s+/g).length / settings.wordsPerMinute) || 1;

instead to get a more accurate word count. Because text() may have multiple consecutive spaces in it, and when split, a bunch of empty elements are all counted towards the word count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions