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

109
Views
how to convert object to list in javascript

Here is my Input Could you all help me out to get the all object based on values as list

{
    Jack: 2,
    olive: 1,
    harry: 2
}

Want my output to be

harry = 2          
olive = 1
jack  = 2

Let me know if there is a way to get the output as mentioned above in javascript

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can use the function Object.entries(object) and loop over all the entries to log the information how you want.

For more information on Object.entries(object) visit https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

const data = {
  Jack: 2,
  olive: 1,
  harry: 2
};

const entries = Object.entries(data);

entries.forEach(([key, value]) => console.log(`${key} = ${value}`));
about 4 years ago · Juan Pablo Isaza Report

0

You could try the following:

const result = Object.entries(theObject).map(([key, value]) => `${key.toLowerCase((} = ${value}`).join(‘\n’);
console.log(result);

Hopefully that helps!

about 4 years ago · Juan Pablo Isaza Report

0

Please check Object.entries() or Object.keys().

Object.entries():- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

Object.keys():- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

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!