refactor: replace for loop with forEach()

https://stackoverflow.com/a/34832466/9645167
This commit is contained in:
curben 2019-05-25 17:49:36 +09:30
parent 3b4172119b
commit 3dfc57dbbe
1 changed files with 3 additions and 3 deletions

View File

@ -9,13 +9,13 @@ searchClick.onclick = function() {
// Add "Copy" button to code snippet // Add "Copy" button to code snippet
const code = document.getElementsByClassName('code') const code = document.getElementsByClassName('code')
for (let i = 0; i < code.length; i++) { Array.from(code).forEach((element) => {
const button = document.createElement('button') const button = document.createElement('button')
button.className = 'copy-button' button.className = 'copy-button'
button.textContent = 'Copy' button.textContent = 'Copy'
code[i].appendChild(button) element.appendChild(button)
} })
/* /*
* Copy button and Cloudinary functions. * Copy button and Cloudinary functions.