how do I display my object into a string? I get the error message:
Uncaught TypeError: Cannot read properties of null (reading 'appendChild') at HTMLButtonElement.detailClickHandler
function detailClickHandler(e) {
let details = e.target
// get the relative id
let hero = details.closest('.card').dataset.id
console.log(hero)
// display hero description
let description = document.createElement('p');
description.innerHTML = hero
detailsContainer.appendChild(description)
}
above in my init function I am calling the html:
//globals
let heroes
let hero
let theData = {}
let detailsContainer
let cardsContainer
function init () {
cardsContainer = document.querySelector(".cards")
detailsContainer = document.querySelector(".detail")