What's the simplest way to make an animation last a precise amount of time?

I’ve been recently having some fun trying to code a simple 2D side scroller. Its jumping code follows a tutorial by Sebastian Lague which uses, among other things, a float called timeToJumpApex to calculate jumping velocity.

However, to accompany that code, I decided to have a jumping animation clip that doesn’t loop — it’s supposed to play only once, starting from whenever the player starts jumping, and ending whenever the character has reached the apex of its jump.

What’s the simplest way to make my jumping animation last precisely as long as my timeToJumpApex variable?

err. since it doesn’t loop. wouldn’t this be linked to the animations overall length and the “power” of the jump?
Seems like a piece of string question?

I have a separate clip for a falling animation, but its currently a short loop. I’m specifically trying to make my jumping animation (i.e. the “going up” part) to last the exact amount of time it takes for the character to actually get to the apex of his current jump.

Since jump height is variable in this little project I’m making, I’d like to make the animation length to also be variable. How can I do it?