Rocket Lawyer interview question

There was this coding question in Typescript