Nearform Interview Question

Just solve the code and write tests