Apply new format to snippets and template
This commit is contained in:
@ -5,10 +5,10 @@ tags: date,math,string,intermediate
|
||||
|
||||
Returns the human readable format of the given number of milliseconds.
|
||||
|
||||
Divide `ms` with the appropriate values to obtain the appropriate values for `day`, `hour`, `minute`, `second` and `millisecond`.
|
||||
Use `Object.entries()` with `Array.prototype.filter()` to keep only non-zero values.
|
||||
Use `Array.prototype.map()` to create the string for each value, pluralizing appropriately.
|
||||
Use `String.prototype.join(', ')` to combine the values into a string.
|
||||
- Divide `ms` with the appropriate values to obtain the appropriate values for `day`, `hour`, `minute`, `second` and `millisecond`.
|
||||
- Use `Object.entries()` with `Array.prototype.filter()` to keep only non-zero values.
|
||||
- Use `Array.prototype.map()` to create the string for each value, pluralizing appropriately.
|
||||
- Use `String.prototype.join(', ')` to combine the values into a string.
|
||||
|
||||
```js
|
||||
const formatDuration = ms => {
|
||||
|
||||
Reference in New Issue
Block a user