Hi!
I am stuck on the end of this project. I would really appreciate any help
Here a link:
https://www.codecademy.com/paths/build-web-apps-with-react/tracks/bwa-modern-javascript-modules-and-browser-compatibility/modules/es-6-modules/projects/es6-modules-workaround
In the console I have found this:
ReferenceError: salaryData is not defined
at getIndustryAverageSalary (workAroundModule.js:27:23)
at HTMLInputElement.updateResults (main.js:67:33)
this is the code where the Console said everything is breaking.
// Add your imports here.
import { getDataByRole, getDataByCompany } from '/modules/salaryData.js';
import resources from '/modules/salaryData.js';
// 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 { getAverageSalaryByRole, getAverageSalaryByCompany ,getSalaryAtCompany, getIndustryAverageSalary };