TypeScript · Exercise 6 of 6 Previous
Intermediate
Migrate a file from JavaScript
This file was renamed from .js to .ts and now has implicit-any errors under the default strict options. Add real types to every parameter and return value, without using any.
totalPrice multiplies each item's price by its qty and adds them. findItem returns the item with that name, or undefined if there is none. The program must print total: 55 and missing: true.
What Check tests
- Your code has no type errors
- The program prints total: 55 and missing: true
- No any
- A price given as text is rejected
- findItem may return undefined
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.