Change element.parentNode.removeChild(element) to element.remove()
element.parentNode.removeChild(element)
element.remove()