⛄ Snowberb ⛄ – 10-46 Jun 1

I'm trying to get the Max and the Min dates from an array of objects, but im having some problems. This is what I've done: startDate: new Date(Math.max(...bonuses.map((bonus) => new Date(bonus.fecha_evento)))) The problem is that typescript is telling me Argument of type 'Date' is not assignable to parameter of type 'number' How can I get the min and the max dates from an array of objects?
S
ScriptyChris687d ago
what is bonus.fecha_evento value exactly?
S
Sniberb687d ago
a string I just fixed it using getTime()
startDate: new Date(
Math.min(...bonuses.map((bonus) => new Date(bonus.fecha_evento).getTime()))
)
startDate: new Date(
Math.min(...bonuses.map((bonus) => new Date(bonus.fecha_evento).getTime()))
)
thank you for answering my question tho <3
S
ScriptyChris687d ago
hmm, i think it's weird TS yells about not assignable number parameter if you passed string there 🤔
S
Sniberb687d ago
yeah that's what I also thought
UU
Unknown User687d ago