Skip to content

Commit e782e4e

Browse files
committed
Store default value for reading speed in constants
1 parent 3bb6318 commit e782e4e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/constants/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Assuming average reading speed of 200 words per minute
2+
export const WORDS_PER_MINUTE = 200;

src/utils/estimateReadingTime.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { WORDS_PER_MINUTE } from '../constants';
2+
13
/**
24
* Estimates the reading time of the text in seconds.
35
* @param {number} wordCount - The number of words in the text.
46
* @returns {number} The estimated reading time of the text in seconds.
57
*/
68
export function estimateReadingTime(wordCount: number): number {
7-
// Assuming average reading speed of 200 words per minute
8-
const wordsPerMinute = 200;
9-
10-
return Math.ceil(wordCount / (wordsPerMinute / 60));
9+
return Math.ceil(wordCount / (WORDS_PER_MINUTE / 60));
1110
}

0 commit comments

Comments
 (0)