Word counter with Vikas Singh
This is my new project after the random joke generator using an API- application programming interface. So in this post, we will be making a basic and advanced word counter.
So lets get started,
ALERT: we will be discussing the javascript part only! If have any queries, comment it out.
Basic word counter!
//create a function that counts the length of the input string!
//use string.length to get the length of the string
//then replace the output to the using innerHTML
//make a proper sentence to show to the client like
245 words out of 50000 characters
Advanced word counter
Resource: https://codepen.io/lalwanivikas/pen/gMLQoz?editors=0010
ALERT: this will take 2 or more days to develop.
Also we will be discussing the js part only
Expected Features :
character counter
word counter
sentence counter
para counter
reading time
readability score
Workflow:
//select all the elements of HTML page by using the query selector.
//Add an event listener to the input- to update the stats on every keypress
//This event listener will trigger a function that will perform the task of updating the stats.
//count the character and replace the output using innerHTML
//detect a word by space, count, update
// Detect a sentence by full stop..., count it, update it
//Detect a para by empty lines, count, then update
//Now its time to calculate READING TIME. For instance, assume that it takes 1 minute to read 275 words for a normal person. So,
275 words in = 60 sec
input word in= (60/275)*input words
Then convert this seconds into minutes. Replace the output using innerHTML.
//TOP KEYWORDS: First we will create an array to remove all the stop words.
Then create another array to store the keywords and their count.
Sort that Keyword array and then display the top four keywords with their count.
//READABILITY SCORE
For this purpose, we will use an API - Mashape.
First, we will add an event listener to the READABILITY element. This event listener on click will trigger a function that will calculate the readability score.
Then we will create a request object (request.setRequestHeader), add the Mashape API key, onload request.
Then we will create an error function.
Then we will use SWITCH STATEMENTS to show the client a meaningful readability score.
top keywords
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home