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

151
Views
Problems sending a object key to another object (Node)

I am trying to send variable Quantity to another object that shares the same ID for Product. (I am using MongoDB) It even logs the result specified below but then an error happens

for (let i = 0; i < product.length; i++){
    for (let j = 0; j < cartRegistry.length; j++){
        if ( cartRegistry[i].ProductId === (product[j]._id.toString()) ){
           console.log(product[j]._id.toString())
           console.log(cartRegistry[i].ProductId, product[j]._id)
           console.log('true')
           
           
        }
        /* console.log(quantity[i].id === product[j]._id.toString()) */
    }
}

C:\Users\Toni\Documents\Aulas Node\store\routes\cart.js:22 if ( cartRegistry[i].ProductId === (product[j]._id.toString()) ){ ^

TypeError: Cannot read properties of undefined (reading '_id') at C:\Users\Toni\Documents\Aulas Node\store\routes\cart.js:22:60

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!