...

/

Coding Challenge: Rewriting Function with Better Types

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.

Access this course and 1400+ top-rated courses and projects.