The .innerHTML property sets or returns the HTML content inside the selected element (i.e. between the tags).
document.querySelector('.card').innerHTML
There's also the rarely used .outerHTML property. .outerHTML represents the HTML element itself, as well as its children.
<h1id="pick-me">Greetings To <span>All</span>!</h1>constinnerResults=document.querySelector('#pick-me').innerHTML;console.log(innerResults);// logs the string: "Greetings To <span>All</span>!"constouterResults=document.querySelector('#pick-me').outerHTML;console.log(outerResults);// logs the string: "<h1 id="pick-me">Greetings To <span>All</span>!</h1>"
.innerText will get the visible text of the element. If CSS is used to hide any text inside that element, .innerTextwill not return that text, while .textContentwill return it.
This is stated above, but I wanted to call this out, specifically. When you're using the .appendChild() method, it must be called on an existing element. To be clear, you can't call this on the document object, so the following will result in an error:
nanodegreeCard.textContent = "I will be the updated text for the nanodegreeCard element!";
// creates and returns a <span> element
document.createElement('span');
// creates and returns an <h3> element
document.createElement('h3');
// create a brand new <span> element
const newSpan = document.createElement('span');
// select the first (main) heading of the page
const mainHeading = document.querySelector('h1');
// add the <span> element as the last child element of the main heading
mainHeading.appendChild(newSpan);
const newSpan = document.createElement('span');
// causes an error
document.appendChild(newSpan);
const myPara = document.createElement('p');
const textOfParagraph = document.createTextNode('I am the text for the paragraph!');
myPara.appendChild(textOfParagraph);
document.body.appendChild(myPara);
const myPara = document.createElement('p');
myPara.textContent = 'I am the text for the paragraph!';
document.body.appendChild(myPara);