dynamic function to change icons

PHOTO EMBED

Tue Oct 29 2024 22:11:40 GMT+0000 (Coordinated Universal Time)

Saved by @davidmchale #js #dynamic-function

function updateIcons(update) {
    const icons = {
      ppt: "powerpoint",
      pptx: "powerpoint",
      doc: "word",
      docx: "word",
      xls: "xcel",
      xlsx: "xcel",
      pdf: "pdf",
      default: "page",
    };

    return icons[update] ?? "page";
  }
    
     <section class="fileDownload__wrapper">
          <div class="fileDownload__icon icon__${updateIcons(fileType)}"
			aria-hidden="true"></div>
       </section>`;
    
content_copyCOPY