Estoy tratando de configurar el pie de página de Font Awesome con JS para poder agregarlo al pie de página, pero no puedo, porque aparece como [object HTMLElement] 2020 - 2021 . Importé el script para Font Awesome pero no funciona.
Me gustaría que el pie de página se muestre como © 2020 - 2021, pero en su lugar use el logotipo de Font Awesome.
document.body.onload = footer; function footer() { // create a new div element const footerDiv = document.createElement("footer"); // assign it a class footerDiv.classList.add("footer"); // gets the current date const copyright = new Date().getFullYear(); // gets the copyright symbol const favicon = document.createElement("i"); favicon.classList.add("fas.fa-copyright"); const completedFooter = document.createTextNode(favicon + " 2020 " + "- " + copyright); // add the text node to the newly created div footerDiv.appendChild(completedFooter); // add the newly created element and its content into the DOM const newDiv = document.getElementById("div"); document.body.insertBefore(footerDiv, newDiv); } <head> <script defer src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/js/all.min.js"> </script> </head>Debe agregar el elemento, no agregarlo como texto a un nodo de texto. También está agregando las clases incorrectamente al elemento i .
document.body.onload = footer; function footer() { // create a new div element const footerDiv = document.createElement("footer"); // assign it a class footerDiv.classList.add("footer"); // gets the current date const copyright = new Date().getFullYear(); // gets the copyright symbol const favicon = document.createElement("i"); favicon.classList.add("fas", "fa-copyright"); const text = document.createTextNode(" 2020 " + "- " + copyright); // add the text node to the newly created div footerDiv.appendChild(favicon); footerDiv.appendChild(text); // add the newly created element and its content into the DOM const newDiv = document.getElementById("div"); document.body.insertBefore(footerDiv, newDiv); } <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet"/>