Programming/JavaScript
Arrow Functions
sunny.ryu
2022. 9. 3. 11:47
// Arrow function
const calcAge3 = birthYear => 2037 - birthYear;
const age3 = calcAge3(1988);
console.log(age3);
const yearsUntilRetirement = (birthYear, firstName) => {
const age = 2037 - birthYear;
const retirement = 65 - age;
// return retirement;
return `${firstName} retires in ${retirement} years`;
}
console.log(yearsUntilRetirement(1988, 'Sunny'));
// prints Sunny retires in 16 years