R
Reactiflux

⛄ Snowberb ⛄ – 10-46 Jun 1

⛄ Snowberb ⛄ – 10-46 Jun 1

S⛄Snowberb⛄6/1/2022
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?
SScriptyChris6/1/2022
what is bonus.fecha_evento value exactly?
S⛄Snowberb⛄6/1/2022
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
SScriptyChris6/1/2022
hmm, i think it's weird TS yells about not assignable number parameter if you passed string there 🤔
S⛄Snowberb⛄6/1/2022
yeah that's what I also thought
UUUnknown User6/1/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

⛄ Snowberb ⛄ – 10-46 Jun 1

Join Server