Merge branch 'master' into new-snippets

This commit is contained in:
Angelos Chalaris
2018-09-01 13:08:18 +03:00
committed by GitHub
11 changed files with 1608 additions and 1606 deletions

View File

@ -19,7 +19,7 @@ const formatDuration = ms => {
};
return Object.entries(time)
.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(', ');
};
```

View File

@ -2,12 +2,12 @@
Hides all the elements specified.
Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified.
Use `NodeList.prototype.forEach()` to apply `display: none` to each element specified.
```js
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
const hide = els => els.forEach(e => (e.style.display = 'none'));
```
```js
hide(...document.querySelectorAll('img')); // Hides all <img> elements on the page
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
```