Skip to main content
TypeScript Bug Hunt Easy +10 XP

Type Mismatch

TypeScript reports an error on this assignment.

TypeScriptFind the bug
1let count: number = "42";
The bug is on line 1

Select the correct fix

Show answer and explanation

Answer: Both B and C fix it

You can't assign a string to a number type. Either convert with Number() or cast with as number (though casting hides bugs).

Hint: String '42' is not the same as number 42.

What this challenge tests

Bug Hunt in TypeScript: types, assignment.

Related challenges