DianApps interview question

Core js , logical coding