Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
insertAdjacentHTML is inserting a comma after every loop

I am trying to loop gifts but the issue is after each object insertAdjacentHTML is inserting a comma, How can I be able to remove the comma?

            document.querySelector(`.chat-content`)?.insertAdjacentHTML(
              'beforeend',
              `<div class="gifts flex items-center h-20 gap-2">
                    ${gifts.map((gift: any) => `
                        <div class="gift bg-skin-field text-primary-yellow">
                            <i class="fas fa-gift"></i>
                            <span class="text-gray-400">${gift.channelId}</span>
                            <span>$${gift.price}</span>
                        </div>
                        `,
          )}
                </div>`,

enter image description here

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

gifts.map(.....) returns an array, which by default stringifies using a comma as delimiter. You'll want to explicitly convert this array to a string yourself, specifying there should be no delimiter:

${gifts.map(.....).join("")}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!