Implemented task2 using TypeScript.