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

256
Views
Verifique si existe un elemento en la matriz pero no realice ninguna tarea javascript

Así que me han encargado que haga un motor de flujo de trabajo básico. Lo tengo revisando el archivo de configuración en busca de dependencias y luego realizando la siguiente función. lo que me gustaría es verificar si el elemento ya existe y no enviarlo a la matriz de salida. He intentado .includes() y .indexOf() pero parece que no puedo hacer que funcionen.

 const TestWorkflowConfig = { insertDetails: { dependencies: [], workflow: { name: "updateRow", id: 10 }, description: "This is a test function where details need to be entered (row update)", data: {}, taskName: "insertDetails", }, detailsConfirmed: { { insertDetails: { isRequired: true; } } dependencies: ["insertDetails"], workflow: { name: "updateRow", id: 10; }, description: "this is to confirm details (update row status)", data: {}, taskName: "detailsConfirmed", }, sendConfirmationEmail: { dependencies: ["detailsConfirmed"], workflow: { name: "sendEmail", id: 8; }, description: "this is a test email to send out to confirm details (send email workflow)", data: { name: "james", email: "james@email.com", body: "this is a test email please ignore"; }, taskName: "sendConfirmationEmail", }, }; const taskQueue = [ { "processName": "sendConfirmationEmail", "isComplete": false }, { "processName": "detailsConfirmed", "isComplete": false }, { "processName": "insertDetails", "isComplete": true } ]; const workflowTaskQueue = []; const config = TestWorkflowConfig; const completedJobs = []; for (const element of taskQueue) { if (element.isComplete === true) { completedJobs.push(element.processName); } } for (const element in config) { if (config[element].dependencies <= 0) { // I would like to check if the "config[element]" is in the completedJobs array and only push if it is not there. workflowTaskQueue.push({ json: config[element] }); } else { const dependencies = config[element].dependencies; const dep = []; for (const el of dependencies) { dep.push(el); const result = dep.every((i) => completedJobs.includes(i)); if (result === true) { // and again I would like to check if the "config[element]" is in the completedJobs array and only push if it is not there workflowTaskQueue.push({ json: config[element] }); } } console.log("taskQueue: " + taskQueue); console.log("completedJobs: " + completedJobs); console.log("output:" + workflowTaskQueue); } }

como siempre cualquier ayuda es muy apreciada.

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!