This is the append function I'm using
function append(parent, el) {
return parent.appendChild(el);
}
And this is where it's being used
let container = document.getElementById("container");
let line = createNode("p");
let line2 = createNode("p");
let line3 = createNode("p");
line.innerHTML = data[key][0];
line2.innerHTML = data[key][1];
//this line checks if there is a third type to be displayed
if (typeof data[key][2] !== "undefined") {
line3.innerHTML = data[key][2];
}
append(container, line);
append(container, line2);
append(container, line3);
The console error always comes back as Cannot read properties of null (reading 'appendChild')
Which part of the appendChild is null?