Created
July 9, 2018 20:16
-
-
Save cezarneaga/56e5b19f29d8adf1d0d75f3e54a23819 to your computer and use it in GitHub Desktop.
display approximate reading time
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
countWords = text => { | |
return text.split(/\s+/).length | |
} | |
const words = this.countWords(article.body) | |
const readTime = Math.round(words / 250) | |
const minutes = readTime === 1 ? 'minute' : 'minutes' | |
//Render this | |
Aproximately {readTime} {minutes} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment