Sometimes you have a value typed as unknown, but you know it is a string at this point. An assertion lets you say “treat this as a string.” It only affects types; it does not convert the value at runtime.
Prefer real checks when possible. Here we will assert because the input is guaranteed by the caller in this small example.
function double(x: unknown) {
return (x as number) * 2;
}
Make a function that returns the uppercased string.