Type Inference
You do not always have to write the type. When you give a variable a value, TypeScript infers its type.
Exampletypescript
The type is still locked in. Assigning a different type later fails, even without an annotation.
Exampletypescript
A good habit: let TypeScript infer simple variables, and write types where inference cannot see them, such as function parameters.
Quick check
What type does TypeScript infer for `let price = 9.99;`?
Your turn: write the code
TypeScript infers count as a number. Add 4 to it and print the result.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.