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

141
Views
¿Agregar un objeto en una matriz en javascript a través del código?

Mi maestro hizo una matriz en mi archivo javascript que no puedo cambiar. Se supone que debo agregarle nuevos objetos a través del código sin tocar esa matriz.

Así es como se ve mi matriz:

 const words = [{ dutch: "vork", english: "Fork", dutchDescription: "Iets waarmee je eet dat doorgaans vier tanden heeft.", englishDescription: "Something you eat with that usually has four tines.", isknown: false }, { dutch: "mes", english: "knife", dutchDescription: "Bestek dat snijdt.", englishDescription: "Cutlery that cuts.", isknown: false }, { dutch: "lepel", english: "spoon", dutchDescription: "Bestek waarmee je soep eet.", englishDescription: "Cutlery you use to eat soup.", isknown: false } ];

Traté de hacerlo así:

 function addCustomWord(object) { const words2 = [{ dutch: "testDutch", english: "testEnglish", dutchDescription: "dutchDiscriptionTest", englishDescription: "englishDiscriptionTest", isknown: false }] words.push(words2); }

Eso claramente no funciona y estoy teniendo dificultades para tratar de encontrar algo que realmente funcione. He estado probando soluciones muy diferentes durante horas y no puedo encontrar nada que funcione. ¿Alguien podría ayudarme con mi problema?

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

0

Elimine los corchetes de las palabras 2 porque la palabra dos es el elemento que necesita agregar

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!