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

100
Views
having issues pushing object to array

Having issues with a simple push here, not understanding what is going on, I'm sure the answer is simple. Any advise here? Every time I log the array I'm trying to push to, it shows empty, however, the object that I am trying to push is loggable. Script is supposed to parse through a bunch of json files in order to combine and normalize the data inside. Using node.

const fs = require('fs');

let mergedobj = [];


const straindir = '../Strain Data/strains';
const terpdir = JSON.parse(fs.readFileSync('../Terpene Data/terp data.json'));
const cannadir = JSON.parse(fs.readFileSync('../Terpene Data/Cannabinoid Data.json'));



fs.readdir(straindir,(err,i)=>{
    if(err){
        console.log(err)
    }
    i.forEach(e =>{
       const strainName = JSON.parse(fs.readFileSync(`../Strain Data/strains/${e}`))[0][1].toString();
       let middleobj = {};
       let j = 0;
       cannadir.forEach( i=>{
           if(i.tag === strainName){
               middleobj[i.tag+' Cannabinoids '+ j] = i;
               j++;
           }
       })
       mergedobj.push(middleobj)
    })
    
})

console.log(mergedobj)
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!