0

Function returning NaN?

Hello friends I did an example for the first class function topic I did a function called calcAge that gets the user's date of birth and calculates the user's age, and using the first class function, the checkAge function gets the age calculation, but whatever I do, the second function gets the first function as an argument. Has returned the value of NaN const calcAge = (brithDay) => { const ageResult = 2021 - brithDay; return ageResult } console.log(calcAge(1992)) const checkAge = (age) => { return age() } console.log(checkAge(calcAge))

21st Nov 2021, 9:30 AM
Hadital
Hadital - avatar
1 Respuesta
+ 2
while calling the function calcAge, u didnt pass any arguments. the birthDay value is null; const calcAge = (brithDay) => { const ageResult = 2021 - brithDay; return ageResult } console.log(calcAge(1992)) const checkAge = (age, args) => { return age(args) } console.log(checkAge(calcAge, 1999))
21st Nov 2021, 10:04 AM
ACE
ACE - avatar