Coding Challenge 3

Introducing The Week 3 Coding Challenge!

For our "Learn to Code with Project Shift Community" we're introducing a weekly coding challenge! Each Tuesday, we'll announce what the challenge is, and on the following Tuesday, we'll post a solution video, along with the names of the winners! If you're not on the email list, you can join here!

As you complete the challenges, you'll be eligible for awesome prizes!


Week 3 Challenge

Imagine you have a company and you're attempting to figure out how profitable your company was in 2019. Given the following data:

const finances = [
  { date: 1546300800, revenue: 10000, expenses: 9000 },
  { date: 1546387200, expenses: 8500 },
  { date: 1548979200, revenue: 20000, expenses: 8000 },
  { date: 1551398400, revenue: 15352, expenses: 5425 },
  { date: 1555286400, revenue: 6, expenses: 10000 },
  { date: 1556841600, revenue: 23000, expenses: 15000 },
  { date: 1559692800, expenses: 2000 },
  { date: 1563062400, revenue: 8500, expenses: 150 },
  { date: 1565827200, revenue: 46000, expenses: 20000 },
  { date: 1568505600, revenue: 34000, expenses: 18000 },
  { date: 1572048000, revenue: 34000, expenses: 18000 },
  { date: 1577664000, revenue: 34000, expenses: 18000 }, 
  { date: 1577664000, expenses: 18000 }
];

Write 2 functions.

One function will be called `maxProfitMonth` and should return the name of the month (i.e. January, February, etc.) that was the most profitable.

The other function will be called `profitLoss` and it should return what the overall profit/loss was for the entire year.

Note that the `date` property is a unix timestamp. Most months only have 1 piece of data, but some have more.


Submitting The Challenge

You may submit your challenge via this form: https://projectshift.typeform.com/to/kvgLGW

Note that the form allows you to submit the challenge in a variety of formats.

Next Tuesday (June 30), we will email you with solutions.