Pregunta de entrevista de Amdocs

Sample JS code examples and need to optimize that