Skip to content

Instantly share code, notes, and snippets.

@night-fury-rider
Last active July 3, 2020 13:35
Show Gist options
  • Save night-fury-rider/c5cc139121e6a47a132d65e2fda1c7eb to your computer and use it in GitHub Desktop.
Save night-fury-rider/c5cc139121e6a47a132d65e2fda1c7eb to your computer and use it in GitHub Desktop.
What we need is closure - Basic
var sodexoAmount = 25;
function getSalary(baseSalary) {
var transportAmount = 50;
function calculateSalary(hraAmount) {
var specialAllowance = 75;
return specialAllowance + hraAmount + baseSalary + transportAmount + sodexoAmount;
}
return calculateSalary;
}
var monthlySalary = getSalary(100);
console.log(monthlySalary(125));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment