PARTech interview question

Asked to perform some tasks in Javascript