Perfios Software Interview Question

Basic JavaScript concepts. Coding problem.