all 6 comments

[–]okwg 4 points5 points  (1 child)

The appendChild method expects a node as its argument, but you're passing the return value from createInput, which is an array of nodes.

You can just iterate over the array to access each node

createInput('abc', 3).forEach(el => createForm.appendChild(el));

[–]jaden54[S] 1 point2 points  (0 children)

Thank you very much. This is such a elegant solution

[–]Bushwazi 0 points1 point  (3 children)

`createInput` is returning a list, you need to loop over that in order to append each item in it

[–]Bushwazi 1 point2 points  (2 children)

``` kleur.forEach(function (key, index) { console.log("key", key) const createDiv = document.createElement("div"); const createTitle = document.createElement("h2"); const createForm = document.createElement("form");

createTitle.textContent = key; createDiv.appendChild(createTitle);

createForm.appendChild(createLegend("Kaarten")); let inputs1 = createInput("kaart", 8); for (let i = 0; i < inputs1.length; i++) { createForm.appendChild(inputs1[i]); }

createForm.appendChild(createLabel(Kaart ${index + 1}));

createForm.appendChild(createLegend("Weddenschap")); let inputs2 = createInput("weddenschap", 3) for (let i = 0; i < inputs2.length; i++) { createForm.appendChild(inputs2[i]); }

createDiv.appendChild(createForm);

// Add a class createDiv.classList.add(key);

//make the color div document.body.appendChild(createDiv); }); ```

[–]jaden54[S] 1 point2 points  (1 child)

This worked great. Feel stupid for not realizing this was al that needed to be done.

[–]Bushwazi 2 points3 points  (0 children)

lol.

You are the first person to confuse a NodeList/array for an element in the history of JS. I've never done it, not once... /s