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

198
Views
How to print key and value of an array of objects

I have an array of objects. Is it possible to print key values using array.map method?

<div> +
array.map( x => {
return `<span class="key">"value"</span><br>
}) +
</div>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try mapping through Object.keys() of every object in the array this way

<div>
  array.map( obj => {
    return obj.keys().map( key => {
      return `<span class="${key}">${obj[key]}</span><br>`
    )}
  })
</div>
about 4 years ago · Juan Pablo Isaza Report

0

Try something like this:

const array = [{
  key: '1',
  value: 'value-1'
}, {
  key: '2',
  value: 'value-2'
}];
const text = array.map(x => `<span class="${x.key}">${x.value}</span><br>`).join("");
const element = document.querySelector('#log');
element.innerHTML = text;
<div id="log"></div>

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!