Skip to content

Commit

Permalink
time-commit (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
meetarora10 authored Aug 8, 2024
1 parent 4e47bb0 commit 9192223
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions Vanilla-JS-Projects/Basic/Word-Counter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h1>Word Counter</h1>
<h2>Count Results</h2>
<p id="word-count">Words: 0</p>
<p id="letter-count">Characters: 0</p>
<p id="read-time">Reading time: 0</p>
</div>
</div>
</div>
Expand Down
13 changes: 10 additions & 3 deletions Vanilla-JS-Projects/Basic/Word-Counter/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand All @@ -22,4 +27,6 @@ function countWords(text) {
function countLetters(text) {
return text.replace(/\s+/g, '').length;
}

function getTime(count){
return (count/250);
}
2 changes: 1 addition & 1 deletion Vanilla-JS-Projects/Basic/Word-Counter/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ h1 {
}

.container {
margin-top: 100px;
margin-top: 50px;
margin-left: 450px;
background: rgba(255, 255, 255, 0.1);
padding: 20px;
Expand Down

0 comments on commit 9192223

Please sign in to comment.