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

89
Views
create dinamically nested object inside double loop forEach

I'm attempting to create a nested object with the same name but different value in this way : example..

const myTestfunction =():void=> {

    const licenses = {};

    valsLicenses.forEach((valLicense) => {
       let license:any = {};
       valLicense.forEach((elem, i, arr) => {
          
          license["licenseId"] = arr[0];
          license["expireDate"] = arr[1];
          license["os"] = arr[2];
          Object.assign(licenses, license);
        });
      });
};

result of this is : enter image description here

and i'd want a JSON object something like this {license:{...},license:{...},license:{...}}

Nevertheless, when I check the object, only the last three value are stored inside the object, i think that this happens because when the object is initialized, the object's address does not change, but I do not spot a solution to add a newly initialized object with the same name inside the same object...how could I resolve it?

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