Arrow Function : In Javascript this is special form of function expression.You dont need to write function keyword.
// Simple arrow function in JS
const age = (birthYear) => 2021 - birthYear ;
const displayAge = age(1990);
console.log(displayAge);
// Calculate Retirement Age Using Arrow Function
const retirementCalc = (birthYear, firstName) => {
const age = 2021 - birthYear;
const retirement = 65 - age;
return `${firstName} will be retire in ${retirement} Years`;
}
console.log(retirementCalc(1975, 'Anil'));
console.log(retirementCalc(1990, 'Sumit'));
0 comments
Post a Comment