Use destructuring and template string for formatDuration (#720)
This commit is contained in:
committed by
Felix Wu
parent
566d4b3a0b
commit
44eea3e9ed
@ -19,7 +19,7 @@ const formatDuration = ms => {
|
|||||||
};
|
};
|
||||||
return Object.entries(time)
|
return Object.entries(time)
|
||||||
.filter(val => val[1] !== 0)
|
.filter(val => val[1] !== 0)
|
||||||
.map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0]))
|
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const formatDuration = ms => {
|
|||||||
};
|
};
|
||||||
return Object.entries(time)
|
return Object.entries(time)
|
||||||
.filter(val => val[1] !== 0)
|
.filter(val => val[1] !== 0)
|
||||||
.map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0]))
|
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
module.exports = formatDuration;
|
module.exports = formatDuration;
|
||||||
|
|||||||
Reference in New Issue
Block a user