💾newElement()

💾 replit: elem.showNote()

// ⭐️ newElement()
/*
 * create and configure a new Element
 * 
 * @param {string}   tagName  - like 'div', 'span' ...
 * @param {function} config   - function to configure the newly created element
 * @return {Element}
 */
function newElement(tagName, config) {
    let elem = document.createElement(tagName);
    if (config) { config(elem) }
    return elem;
}

Last updated