const blockSelector = '.block';
const buttonSelector = `${blockSelector} .block__close`;
document.addEventListener('click', e => {
const block = e.target.closest(buttonSelector)?.closest(blockSelector);
block?.parentNode.removeChild(block);
});
document.querySelectorAll(buttonSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => e.currentTarget.closest(blockSelector).remove());