Deviopath › TypeScript

Display Name with ??

Easy · Null Safety

Write displayName(nickname: string | null | undefined, fallback: string): string that returns the nickname, or fallback when the nickname is null or undefined.

Use the ?? operator. Unlike ||, it keeps an empty string "" instead of replacing it.

Next: Sort a Readonly Array