0 of 6 problems solved0%
1 of 6

Get Username Length (Explicit Return)

Understanding return type annotations helps readers (and the compiler) know exactly what a function produces. Here, you’ll write a tiny function that returns the length of a username. You’ll annotate the parameter as a string and the return type as a number.

Annotating return types is especially helpful in foundational functions, library APIs, and when inference might be ambiguous.

Your Task

  • Complete the function getUsernameLength(username: string): number.
  • The function should return the length of username.
  • Do not log anything in this problem; just return a number.

Examples

  • getUsernameLength('TypeUser') → 8
  • getUsernameLength('TS') → 2