-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_5.js
35 lines (31 loc) · 1.47 KB
/
task_5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
For each employee their current salary is calculated by multiplying yearly increment with experience then adding the result to the starting salary. Now calculate is the total salary has to be provided by the company in a month.
const employees = [
{ name: "shahin", experience: 5, starting: 20000, increment: 5000 },
{ name: "shihab", experience: 3, starting: 15000, increment: 7000 },
{ name: "shikot", experience: 9, starting: 30000, increment: 1000 },
{ name: "shohel", experience: 0, starting: 29000, increment: 4000 },
];
*/
employees = [
{ name: "shahin", experience: 5, starting: 20000, increment: 5000 },
{ name: "shihab", experience: 3, starting: 15000, increment: 7000 },
{ name: "shikot", experience: 9, starting: 30000, increment: 1000 },
{ name: "shohel", experience: 0, starting: 29000, increment: 4000 },
];
function totalSalaryProvidedByCompany(employees) {
let totalSalaryProvidedByCompany = 0;
for (let employee of employees) {
let increasedSalaryByExperience = employee.increment * employee.experience;
let startingSalary = employee.starting;
let employeeGetSalary = increasedSalaryByExperience + startingSalary;
totalSalaryProvidedByCompany =
totalSalaryProvidedByCompany + employeeGetSalary;
}
return totalSalaryProvidedByCompany;
}
const result = totalSalaryProvidedByCompany(employees);
console.log(
"Total Salary has to be provided by the company in a month:",
result
);