The preceding example uses an imperative approach for
calculating the values for each frame
in the animation:
you explicitly provide
values for the frame rate as well as
the value needed to increment
the top margin property for each frame.
Can you think of a way to refactor this example
so that you only need to provide a starting and ending
value for top margin, and leave the rest to an
interpolation function the generates the values
for the frames in between?

Here’s a few hints:

Don’t worry about animating the ball
up and down. Just focus on the first downward motion
of the ball (from a top margin of 0 to top margin of 100).

Try using 60 fps for the frame rate.

For any starting or ending position of the ball,
you can express the amount to increment top margin
between each frame as the difference between the margin’s
starting and ending values divided by the total number of frames.