Calculate Savings

Report a typo

Amal works for MNC. He wants to calculate how much he saves in a month after all expenses are incurred. Amal considers any money that hasn't been spent to be savings. An array of four elements represents Amal's expenses in a single month. Calculate how much Amal has saved after incurring all these expenses.

Read the information below and output the expected result:

  • Monthly salary is 25000.
  • Calculate the remaining salary after expenses by using the reduce() method.
  • The result should be a single value.
  • Use console.log inside the function to output the result.

Sample Input 1:

200 1000 300 550

Sample Output 1:

22950
Write a program in JavaScript
const salary = 25000;

function getSalary(expenses) {
let remainingSalary = ...
}
___

Create a free account to access the full topic