You have been given unfinished TypeScript code with typos. The ageOfMan function has an incorrect return type. Also, all function arguments do not indicate that they are optional. The last point is that you need to specify an explicit type for the age argument. Fix the ageOfMan function to make the code work!
What is TypeScript?
The age of man
Report a typo
Write a program in TypeScript
function ageOfMan(age, name: string): void { //Change this line!
return `${name ?? "User"} ${age ?? 18} years old!`
}
const message: string = ageOfMan();
console.log(message);
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.