Altametrics Interview Question

Presented me with a more complex typescript question