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 2 object into single one

i've got 2 objects

const size = shoppingCart.map((el) => ({size: el.size}));

The first one is filteredProducts list:

    const filteredProducts = [
    {
        description: "Material: 100% cotton\nCare instructions: Do not tumble dry, machine wash at 30 ° C, machine wash on gentle cycle",
        id: "80005397",
        image: {url: 'h,ttps://www.datocms-assets.com/59095/1638273249-spodnie.png'},
        price: 32.8,
        title: " Pier One Cargo"
    }
]

And second one that is selected size:

  const selectedSize = [
    {
        size: 'L'
    }
]

I have to combine this 2 objects into single one like this:

    const filteredProducts = [
    {
        description: "Material: 100% cotton\nCare instructions: Do not tumble dry, machine wash at 30 ° C, machine wash on gentle cycle",
        id: "80005397",
        image: {url: 'h,ttps://www.datocms-assets.com/59095/1638273249-spodnie.png'},
        price: 32.8,
        title: " Pier One Cargo",
        size: 'L'
    }
]
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You can use map() function and the spread operator:

const filteredProductsWithSize = filteredProducts.map((product, i) => ({
    ...product,
    ...selectedSize[i]
}));
about 4 years ago · Santiago Gelvez 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!