Last active
March 18, 2017 06:15
-
-
Save felquis/e547ef0db08df8c453608de7e5a45c7d to your computer and use it in GitHub Desktop.
How much time would I take to read a web page?
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
// output is in minutes | |
document.body.innerText.split(' ') | |
.filter((split) => split.length > 1) | |
.map((split) => split.replace(/[^a-zZ-a]+/g, '')) | |
.filter((split) => split.length > 1) | |
.reduce((acc, split) => { | |
const time = split.split('').length * 115 | |
return [...acc, (time > 500) ? time : 500] | |
}, []) | |
.reduce((acc, time) => ([acc[0] + time]), [0]) | |
.map((time) => (time / 1000 / 60)) | |
// instead of using document.body, you can select only the main content of your page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment