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

81
Views
How to Remove duplicate from array in js using set and put each item in li tag ....below is my code

const xx = [" 4", "9", "16"," 4", "9", "16"," 4", "9", "16"]

<ul> {(<li> {[...new Set(xx)]} </li>)} </ul>

const xx = [" 4", "9", "16"," 4", "9", "16"," 4", "9", "16"]

    {(
  • {[...new Set(xx)]}
  • )}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here, this would work fine

const xx = [" 4", "9", "16"," 4", "9", "16"," 4", "9", "16"];
const set = [...new Set(xx)];
let html = '';
set.forEach(el => {
    html += `<li>${el}</li>`;
});

document.querySelector("#list").insertAdjacentHTML('afterbegin', html);
<ul id="list"></ul>

You could also do the same with the array methods

const xx = [" 4", "9", "16"," 4", "9", "16"," 4", "9", "16"];
const html = [...new Set(xx)].map(el => `<li>${el}</li>`).join('');
document.querySelector("#list").insertAdjacentHTML('afterbegin', html);
<ul id="list"></ul>

about 4 years ago · Juan Pablo Isaza 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!