From 3f2744e9e5fac20c9d758c39accc572204f9d34e Mon Sep 17 00:00:00 2001 From: howardbdev Date: Tue, 20 Jul 2021 16:34:10 -0400 Subject: [PATCH 1/2] fix snippets/hide.md --- snippets/hide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/hide.md b/snippets/hide.md index 89a544d39..c4d1af1a8 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -10,7 +10,7 @@ Hides all the elements 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 = nodes => nodes.forEach(e => (e.style.display = 'none')); ``` ```js From e35b4e0bb36d1e45e1a659edd8ba1ce03418b146 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Fri, 23 Jul 2021 16:08:32 +0300 Subject: [PATCH 2/2] Update hide.md --- snippets/hide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/hide.md b/snippets/hide.md index c4d1af1a8..fc9d6dd9b 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -7,12 +7,12 @@ lastUpdated: 2020-09-15T16:28:04+03:00 Hides all the elements specified. -- Use `NodeList.prototype.forEach()` to apply `display: none` to each element specified. +- Use the spread operator (`...`) and `Array.prototype.forEach()` to apply `display: none` to each element specified. ```js -const hide = nodes => nodes.forEach(e => (e.style.display = 'none')); +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); ``` ```js -hide(document.querySelectorAll('img')); // Hides all elements on the page +hide(...document.querySelectorAll('img')); // Hides all elements on the page ```