Skip to content

Commit

Permalink
Update. Export data corectly.
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviuPe committed Feb 11, 2024
1 parent 812f45e commit 87012ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Calculators/Word-Count-Calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<p id="result">
<span class="total-words">Total words: 0</span> |
<span class="unique-words">Unique words: 0</span> |
<span class='total-words'>Shortest words: 0</span> |
<span class='total-words'>Longest words: 0</span> |
<span class='shortest-words'>Shortest words: 0</span> |
<span class='longest-words'>Longest words: 0</span> |
<span class="average-length">Average Word Length: 0.00 characters</span>
</p>
<button onclick="exportData()">Export Data</button>
Expand Down
6 changes: 4 additions & 2 deletions Calculators/Word-Count-Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function countWords() {
document.getElementById("result").innerHTML =
"<span class='total-words'>Total words: " + totalWords + "</span> | " +
"<span class='unique-words'>Unique words: " + uniqueWords + "</span> | " +
"<span class='total-words'>Shortest words: " + shortest_count + "</span> | " +
"<span class='total-words'>Longest words: " + longest_count + "</span> | " +
"<span class='shortest-words'>Shortest words: " + shortest_count + "</span> | " +
"<span class='longest-words'>Longest words: " + longest_count + "</span> | " +
"<span class='average-length'>Average Word Length: " + averageWordLength.toFixed(2) + " characters</span>";
}
function shortestWord(wordsArray) {
Expand Down Expand Up @@ -80,6 +80,8 @@ function exportData() {
var data = {
text: text,
totalWords: wordsArray.length,
shortestWord: shortestWord(wordsArray).length,
longestWord: longestWord(wordsArray).length,
uniqueWords: countUniqueWords(wordsArray),
averageWordLength: calculateAverageWordLength(wordsArray).toFixed(2)
};
Expand Down

0 comments on commit 87012ad

Please sign in to comment.