-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkAroundModule.js
More file actions
37 lines (33 loc) · 1.54 KB
/
workAroundModule.js
File metadata and controls
37 lines (33 loc) · 1.54 KB
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
36
37
// Add your imports here.
import { getDataByRole } from "./modules/salaryData.js";
import { getDataByCompany } from "./modules/salaryData.js";
// Replace the empty array with the appropriate imported function/value
export const getAverageSalaryByRole = (role) => {
const roleData = getDataByRole(role);
const salariesOfRole = roleData.map((obj) => obj.salary);
return calculateAverage(salariesOfRole);
};
// Replace the empty array with the appropriate imported function/value
export const getAverageSalaryByCompany = (company) => {
const companyData = getDataByCompany(company);
const salariesAtCompany = companyData.map((obj) => obj.salary);
return calculateAverage(salariesAtCompany);
};
// Replace the empty array with the appropriate imported function/value
export const getSalaryAtCompany = (role, company) => {
const companyData = getDataByCompany(company);
const roleAtCompany = companyData.find((obj) => obj.role === role);
return roleAtCompany.salary;
};
// Replace the empty array with the appropriate imported function/value
export const getIndustryAverageSalary = () => {
const allSalaries = salaryData.map((obj) => obj.salary);
return calculateAverage(allSalaries);
};
// Helper Function. Do not edit.
// Note: This function does not need to be exported since it is only used by the functions contained within this module.
function calculateAverage(arrayOfNumbers) {
let total = 0;
arrayOfNumbers.forEach((number) => (total += number));
return (total / arrayOfNumbers.length).toFixed(2);
}