- HTML Structure:
- The HTML document includes various elements for creating the user interface, including a
<div>
with the id "root" that contains the entire content. - It includes a heading (
<h1>
) for the page title, an input box for entering words, a "Count" button to trigger the word count, and a textarea to display the word count results.
- The HTML document includes various elements for creating the user interface, including a
- CSS Styling:
- CSS styles are applied to format and style the user interface elements. This includes setting background colors, margins, font sizes, and border radius to create a visually appealing design.
- JavaScript Code:
- The JavaScript code is embedded within the HTML document using a
<script>
tag. -
-
It first retrieves the text entered by the user from the input field with the id "para."
-
The array of key-value pairs is sorted in descending order based on word frequency using the
sort()
method. -
The sorted array is then sliced to limit the output to all entries.
-
Finally, the sorted word count data is displayed in the textarea with the id "output" using
document.getElementById('output').innerHTML
.
-
- The JavaScript code is embedded within the HTML document using a
- User Interaction:
-
When a user enters words into the input box and clicks the "Count" button, the
countWords()
function is called, and the word count results are displayed in the textarea. -
Count-Words-week-5.mp4
-
-
That is currently for only count words Future Improvements include using the slice method in javascript improve count texts for using Javascript are other languages in the future