Coding Challenge: Rewriting Function with Better Types
Apply what you’ve learned about types in the coding challenge in this lesson.
We'll cover the following
Problem statement
We’ve added some imperfect TypeScript types to the function below, which takes two arguments. We’ve discovered that status can only have the values SUCCESS
and FAILED
and that scores are always numbers. The function below allows many illegal parameter types, such as showResult('fake', 'fake')
, to compile when they shouldn’t. Our task in this challenge is to rewrite this function with better types.
Get hands-on with 1400+ tech skills courses.