LINE Interview Question

Using javascript search max profit by the problem input