← Back to challenges

Say Hello to Guests

JavaScriptHardloopsstringsarrays

Instructions

In this exercise you will have to:

  • Take a list of names.
  • Add "Hello" to every name.
  • Make one big string with all greetings.

The solution should be one string with a comma in between every "Hello (Name)".

Examples

greetPeople(["Joe"]) ➞ "Hello Joe"

greetPeople(["Angela", "Joe"]) ➞ "Hello Angela, Hello Joe"

greetPeople(["Frank", "Angela", "Joe"]) ➞ "Hello Frank, Hello Angela, Hello Joe"

Notes

  • Each greeting has to be separated with a comma and a space.
  • If you're given an empty array [], return an empty string "".
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Lexicographically First and Last