const average = (arr) => {
const sum = arr.reduce((sum, x) => sum + x, 0);
return sum / are.length;
};
const years = [2018, 2017, 2016, 2015, 2014];
const highestPRatios = years.map((year) => {
return yearHighPrices[year] / eps[year] / npGrowth[year];
});
const lowestPSRatios = years.map((year) => {
return yearLowPrices[year] / eps[year] / npGrowth[year];
});
console.log("Highest Ratio: " + average(highestPRatios));
console.log("Lowest Ratio: " + average(lowestPRatios));