From 91922238d3bcb4d69c8f9713d7cf105e4020f3b9 Mon Sep 17 00:00:00 2001 From: Meet Arora Date: Thu, 8 Aug 2024 19:22:42 +0530 Subject: [PATCH] time-commit (#758) --- Vanilla-JS-Projects/Basic/Word-Counter/index.html | 1 + Vanilla-JS-Projects/Basic/Word-Counter/script.js | 13 ++++++++++--- Vanilla-JS-Projects/Basic/Word-Counter/style.css | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Vanilla-JS-Projects/Basic/Word-Counter/index.html b/Vanilla-JS-Projects/Basic/Word-Counter/index.html index 2d9343f8..809bde66 100644 --- a/Vanilla-JS-Projects/Basic/Word-Counter/index.html +++ b/Vanilla-JS-Projects/Basic/Word-Counter/index.html @@ -19,6 +19,7 @@

Word Counter

Count Results

Words: 0

Characters: 0

+

Reading time: 0

diff --git a/Vanilla-JS-Projects/Basic/Word-Counter/script.js b/Vanilla-JS-Projects/Basic/Word-Counter/script.js index 36c25f7e..c68ce261 100644 --- a/Vanilla-JS-Projects/Basic/Word-Counter/script.js +++ b/Vanilla-JS-Projects/Basic/Word-Counter/script.js @@ -8,10 +8,15 @@ document.getElementById('count-button').addEventListener('click', () => { const wordCount = countWords(text); const letterCount = countLetters(text); - + const read = getTime(wordCount); + const readTime = read*60; document.getElementById('word-count').textContent = `Words: ${wordCount}`; document.getElementById('letter-count').textContent = `Character: ${letterCount}`; - + if((readTime)<60){ + document.getElementById('read-time').textContent = `Reading time: ${readTime} secs`; + }else{ + document.getElementById('read-time').textContent = `Reading time: ${Math.floor(readTime/60)}:${Math.floor(readTime%60)} mins`; + } document.getElementById('results').classList.remove('hidden'); }); @@ -22,4 +27,6 @@ function countWords(text) { function countLetters(text) { return text.replace(/\s+/g, '').length; } - +function getTime(count){ + return (count/250); +} diff --git a/Vanilla-JS-Projects/Basic/Word-Counter/style.css b/Vanilla-JS-Projects/Basic/Word-Counter/style.css index 5b0a62ea..b603ef13 100644 --- a/Vanilla-JS-Projects/Basic/Word-Counter/style.css +++ b/Vanilla-JS-Projects/Basic/Word-Counter/style.css @@ -69,7 +69,7 @@ h1 { } .container { - margin-top: 100px; + margin-top: 50px; margin-left: 450px; background: rgba(255, 255, 255, 0.1); padding: 20px;