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

236
Views
¿Cómo calculo los tiempos promedio en Typescript?

Tengo un objeto que tiene la siguiente entrada:

 numberOfReturns: number = 0; returns_explanations: string [] = []; departure_time: string = ''; arrival_time: string = '';

Así que en la hora de salida tengo la siguiente información:

 ... departure_time: 08:15 departure_time: 08:02 departure_time: 09:00 ...

Tengo una matriz de todo este objeto que deberá iterarse y necesito obtener los tiempos de salida promedio.

 let average: Date = null; for (let i = 0; i < workAccountItem.length; i++) { average = moment(average).add(moment('01/01/2021 ' + workAccountItem[i].departure_time)); } average = average / workAccountItem.length;

Este enfoque no funcionará.

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

0

En su interfaz de tipo principal, parece que tiene un espacio adicional entre string y [] para returns_explanations ; si está definiendo un accesorio que tiene una matriz de tipo de cadenas, debe ser string[] sin espacio. Para su definición de tipo para average , también puede establecer que sea Date o null , como tal, average: Date | null , que evitará errores de tipo cuando aún no haya una fecha presente.

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!