From 3dfc57dbbe192bf865f5e78fa9122751bd2efabb Mon Sep 17 00:00:00 2001 From: curben Date: Sat, 25 May 2019 17:49:36 +0930 Subject: [PATCH] refactor: replace for loop with forEach() https://stackoverflow.com/a/34832466/9645167 --- themes/typing/source/js/typing.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/typing/source/js/typing.js b/themes/typing/source/js/typing.js index 12f8226..987e3ba 100644 --- a/themes/typing/source/js/typing.js +++ b/themes/typing/source/js/typing.js @@ -9,13 +9,13 @@ searchClick.onclick = function() { // Add "Copy" button to code snippet const code = document.getElementsByClassName('code') -for (let i = 0; i < code.length; i++) { +Array.from(code).forEach((element) => { const button = document.createElement('button') button.className = 'copy-button' button.textContent = 'Copy' - code[i].appendChild(button) -} + element.appendChild(button) +}) /* * Copy button and Cloudinary functions.