Equinix interview question

Basic JS question, hard LC problem