All challenges
Optional Properties
easyinterfaces50 XPProblem
Define an interface UserProfile with a required username (string) and an optional email (string). Write describeUser(user: UserProfile): string that returns "username <email>" when an email exists, or "username (no email)" otherwise. You must narrow the optional property before using it.
Expected output
ada (no email)
grace <grace@navy.mil>Hints
Stuck? Reveal hints one at a time.
Solution
Try solving it yourself first — revealing is always available.
Press Run in the editor — your console output is checked automatically.
No errors
Loading...
Console output appears here. Press Run or just type — the code compiles automatically.