JBCconnect interview question

JS advance problem solving question