function createElement(tagName, attributes, container) {
    const element = document.createElement(tagName);

    for (const key of Object.keys(attributes)) {
        try {
            element[key] = attributes[key];
        } catch (e) {
            element.setAttribute(key, attributes[key]);
        }
    }
    if (container) {
        container.appendChild(element);
    }
    return element;
}
Creates an element with the specified attributes and appends it to a container.
@param {string} tagName - A string that specifies the type of element to be created
@param {Object} attributes - The attributes to set
@param {Element} container - The node to append the element to
@returns {Element} The new Element