Amdocs interview question

Sample JS code examples and need to optimize that