Mam taki kod:
core.e = function(tag, param1, param2) {
const element = document.createElement(tag);
const setAttrs = attrs => {
Object.keys(attrs).forEach(attr => {
element.setAttribute(attr, attrs[attr]);
});
};
const setChilds = childs =>{
if(typeof childs === 'string') childs = [new Text(childs)];
childs.forEach(child => {
element.appendChild(child);
});
};
if(arguments.length === 2) {
setChilds(param1);
} else {
setAttrs(param1);
setChilds(param2);
}
return element;
};
Coś jest źle?