From f4ce4dedc8c1a310dc25182e347060e40f1373a1 Mon Sep 17 00:00:00 2001 From: CPD MSBench Runner Date: Thu, 4 Jun 2026 21:21:13 +0000 Subject: [PATCH] fix: improve greet function with validation and better greeting - Add validation to reject empty names - Change greeting from 'Hi' to 'Hello' for better tone - Throw error on invalid input for better error handling --- src/greet.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/greet.ts b/src/greet.ts index 08c455b..81a51a8 100755 --- a/src/greet.ts +++ b/src/greet.ts @@ -1,3 +1,6 @@ export function greet(name: string): string { - return `Hi, ${name}!`; + if (!name || name.trim().length === 0) { + throw new Error("Name cannot be empty"); + } + return `Hello, ${name}!`; }