Your div element in a document has id=”answers”. If a JS fn sets d=document.getElementById(“answers”), then which is the preferred way to add a paragraph containing the word “Hello”? as a child of that div?

Questions & AnswersCategory: Programming LanguageYour div element in a document has id=”answers”. If a JS fn sets d=document.getElementById(“answers”), then which is the preferred way to add a paragraph containing the word “Hello”? as a child of that div?
Adam asked 2 years ago

Your div element in a document has id=”answers”.  If a JS fn sets d=document.getElementById(“answers”), then which is the preferred way to add a paragraph containing the word “Hello”? as a child of that div?

a. answers.innerHTML = “Hello”;

b. d.appendChild(“Hello “);

c. d.innerHTML = “Hello “;

d. p = createElement(“p”); p.innerHTML = “Hello”; d.appendChild(p);