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

134
Views
How do I display nested objects in javascript
let para = document.createElement('p');
document.body.appendChild(para)

const apple = { 
  color: 'Green',
  price: {
   bulk: '$3/kg',
   smallQty: '$4/kg'
  }
};

let txt = ''
for (let x in apple) {
  txt += apple[x] 
 };

para.innerHTML = txt;

In the browser, I'm getting Green[object Object] thank you

///////////////

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

0

In the 2nd iteration, you are getting an object which is why you are seeing such an output.

Convert apple[x] to a string using JSON.stringify(apple[x]) and this will be your output:

"Green"{"bulk":"$3/kg","smallQty":"$4/kg"}

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!