Why do we need the li.insertBefore(span, input); ?
I do not understand the purpose of putting the insertBefore method to replace the current input.
Steven Parker195,204 Points
insertBefore method is primarily just a way to add the new element to the DOM, and it has the benefit of allowing it to be placed directly before the element that is about to be removed.
Then when the other element is removed, you can be certain that the new one is in exactly the same spot in the DOM arrangement where the other one was previously.
Brian Burkard5,724 Points
I used replaceChild https://developer.mozilla.org/en-US/docs/Web/API/Node/replaceChild
seems to work fine.