Pregunta de entrevista de Oracle

it was a coding question using javascript