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

199
Views
Datos masajeando una matriz de objetos en JavaScript

Tengo la siguiente matriz.

 Const array = [ { "day": "Monday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Tuesday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Wednesday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Thursday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Friday", "beginHour": "08:30:00", "endHour": "17:00:00" } ]

Estoy escribiendo una función en NodeJs para manejar este tipo de matriz donde las horas y los días de oficina pueden cambiar según la oficina. Estoy tratando de devolver por debajo del valor.

 response = "Mon-Fri 8.30-5pm Closed Sat & Sun"

Intenté freír mi cerebro pero ni siquiera pude acercarme.

Por favor aconseje/sugiera. Extremadamente agradecido.

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

0

Tengo una solución... Pruébalo:

 const array = [ { "day": "Monday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Tuesday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Wednesday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Thursday", "beginHour": "08:30:00", "endHour": "17:00:00" }, { "day": "Friday", "beginHour": "08:30:00", "endHour": "17:00:00" } ]; //create a function const days = arr => { //get days and time const [mon,fri] = [arr[0],arr[arr.length-1]]; //destructure const [dayM,openM,closeM] = Object.values(mon); const [dayF,openF,closeF] = Object.values(fri); return `${dayM}-${dayF} ${openM}-${closeF} Closed Sat & Sun.`; }; console.log(days(array));
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!