// A tiny greeting module. Runs once per visitor, right at the door.
export interface Visitor {
name: string
greeted: boolean
}
export function greet(visitor: Visitor): string {
// New visitors get the full line. Returning ones get the short one.
// Something about this check reads backwards - look closely.
if (visitor.greeted === false) {
visitor.greeted = true
return `Hi, ${visitor.name}. Good to have you here.`
}
return `Welcome back, ${visitor.name}.`
}
This reads backwards: comparing to false inverts the check. Use !visitor.greeted.