Skip to content

Commit e432558

Browse files
authored
fix: for loop condition correction and return statement added
1 parent dbc4c80 commit e432558

File tree

1 file changed

+3
-1
lines changed
  • src/pages/2020-07/relative-time-format

1 file changed

+3
-1
lines changed

src/pages/2020-07/relative-time-format/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ const DIVISIONS = [
124124
function formatTimeAgo(date) {
125125
let duration = (date - new Date()) / 1000
126126

127-
for (let i = 0; i <= DIVISIONS.length; i++) {
127+
for (let i = 0; i < DIVISIONS.length; i++) {
128128
const division = DIVISIONS[i]
129129
if (Math.abs(duration) < division.amount) {
130130
return formatter.format(Math.round(duration), division.name)
131131
}
132132
duration /= division.amount
133133
}
134+
135+
return false
134136
}
135137
```
136138

0 commit comments

Comments
 (0)