Skip to content

Instantly share code, notes, and snippets.

@jindeveloper
Created September 1, 2020 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jindeveloper/490fb03cb7d649832348ecf410a14fbe to your computer and use it in GitHub Desktop.
Save jindeveloper/490fb03cb7d649832348ecf410a14fbe to your computer and use it in GitHub Desktop.
const TOTAL_WORKING_DAYS = 261;
//Horrible in my opinion, worst someone will say it is ugly.
const dailyRate = (item, index, array) => array[index].dailyRate = Math.floor(((item.salary * 12) / (TOTAL_WORKING_DAYS)));
//undefined as forEach doesn't return any results.
let dailyRateEmployeeResults = employees.forEach(dailyRate);
console.log(dailyRateEmployeeResults);//undefined
console.log(employees); //With side effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment