Here is the exercise: https://www.codecademy.com/courses/learn-intermediate-javascript/projects/es6-modules-workaround
Everything seems to go well, however, when I try and export the workAroundModule.js into the main.js file, the browser on the right side goes back to not displaying what it should be.
I have tried looking at other people’s fixes and tried them, but to no avail sadly.
Here is my main.js import section
import {getRoles, getCompanies} from './modules/salaryData.js'
import {getIndustryAverageSalary, getSalaryAtCompany, getAverageSalaryByCompany, getAverageSalaryByRole} from './modules/workAroundModule.js'
My workAroundModule.js file:
import {getDataByRole, getDataByCompany} from
'./salary.js'
import resources from './salary.js'
const {salaryData} = resources;
// Replace the empty array with the appropriate imported function/value
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
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
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
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);
}
export {getIndustryAverageSalary, getSalaryAtCompany, getAverageSalaryByCompany, getAverageSalaryByRole};
and lastly, my salaryData.js file:
export {getRoles, getCompanies, getDataByRole, getDataByCompany};
const resources = salaryData;
export default resources;