0

Reading the code

I have couple line of code, can someone help me explain what just happened. It's a JavaScript code (not the first 3 line): const todos = document.querySelectorAll('.todoItem'); const completedTodos = document.querySelector('.completed'); const completedWrapper = document.querySelector('.completedTodoWrapper'); todos.forEach(todo => todo.addEventListener('click', (event) => { let completedTodo = document.createElement('li'); let todoContent = document.createTextNode(todo.textContent); completedTodo.appendChild(todoContent); completedWrapper.insertBefore(completedTodo, completedTodos); todo.remove(); })); Thank you

7th Aug 2019, 12:35 AM
Chrisman
Chrisman - avatar
1 Odpowiedź
+ 1
https://www.sololearn.com/learn/JavaScript/2970/ ES6 syntax version of for loop, and declaring function without the function keyword
7th Aug 2019, 12:48 AM
Gordon
Gordon - avatar