function to create an element javascript

// A function to create elements in JS
function elementFactory(tag, text) {
    const el = document.createElement(tag);
    el.textContent = text;
    return el;
}

const someListItem = elementFactory("li", "some text"); 
let p = document.createElement('p');