Created
July 10, 2018 16:14
-
-
Save alexpana/e924e5e2b61fd28f0d24a1120d0a38ef to your computer and use it in GitHub Desktop.
estimate read time of article in JS
This file contains hidden or 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
WPM = 200; m = Array.from(document.getElementsByTagName("p")).reduce((acc, t) => acc + t.innerHTML, "").split(" ").length / WPM; h = Math.floor(m / 60); m = Math.floor(m % 60); msg = h > 0 ? h+"h "+m+"m" : m+"m";alert("Estimated read time: " + msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment