Write a method greet(name)
that interpolates name
in a simple greeting.
Example: when name
is "Bob"
, the method should return the string "Hello, Bob."
.
Handle nulls by introducing a stand-in.
Example: when name
is null, then the method should return the string "Hello, my friend."
Handle uppercase names by returning an uppercase greeting.
Example: when name
is "JERRY"
then the method should return the string "HELLO JERRY!"
Handle an array of two names.
Example: when name
is ["Jill", "Jane"]
, then the method should return the string "Hello, Jill and Jane."
Handle arrays of 3 or more names.
Example: when name
is ["Amy", "Brian", "Charlotte"]
, then the method should return the string "Hello, Amy, Brian, and Charlotte."
Handle arrays of mixed case names.
Example: when name
is ["Amy", "BRIAN", "Charlotte"]
, then the method should return the string "Hello, Amy and Charlotte. AND HELLO BRIAN!"
Handle arrays of names where a single item in the array contains two names.
Example: when name
is ["Bob", "Charlie, Dianne"]
, then the method should return the string "Hello, Bob, Charlie, and Dianne."
.
Handle deliberate commas indicated by escaped double quotation marks.
Example: when name
is ["Bob", ""Charlie, Dianne""], then the method should return the string
"Hello, Bob and Charlie, Dianne."
.