Javascript Functions Another Example for practice and Understanding.
//function example in Javascript..
const calcAge = function (birthYear) {
return 2031 - birthYear;
}
const retirementCalc = function (birthYear, firstName) {
const age = calcAge(birthYear);
const retirement = 65 - age;
if (retirement > 0) {
console.log(`${firstName} will retire in ${retirement} Years `)
return retirement;
} else {
console.log(`${firstName} already retired`);
return -1;
}
}
console.log(retirementCalc(1950, 'Anil'));
console.log(retirementCalc(1990, 'Amit'));
0 comments
Post a Comment