Last active
February 14, 2019 14:05
-
-
Save vincentorback/6b8c6d14ddb65488a1f2 to your computer and use it in GitHub Desktop.
Reading time / Words per minute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get reading time | |
* @param {String} text The text string to analyze | |
* @return {Int} Reading time in milliseconds | |
*/ | |
function getReadingTime(text) { | |
var totalWords, | |
wordsPerMillisecond, | |
totalReadingTime, | |
wordsPerMinute = 250, | |
wordsPerMillisecond = wordsPerMinute / 60000; | |
text = text.replace(/<\/?[^>]+(>|$)/g, ''); // Remove any HTML-tags | |
totalWords = text.split(/\s+/g).length; // Split up in words | |
totalReadingTime = Math.floor(totalWords / wordsPerMillisecond); | |
return totalReadingTime; | |
} | |
/** | |
# Average word per minute | |
Third-grade students = 150 | |
Eight grade students = 250 | |
Average adult: 300 | |
Average college student = 450 | |
Average “high level exec” = 575 | |
Average college professor = 675 | |
Speed readers = 1,500 | |
World speed reading champion = 4,700 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do fun stuff like this: