Create a Secret Society Name

A group of friends has decided to form a secret society, and they want to choose a unique and organized name for it. The name of the society will be formed using the first letter of each friend’s name, sorted alphabetically.

Instructions:

  • Write a function named createSocietyName that takes one parameter:

    • names: An array of strings, where each string is a name of a friend.
  • The function should return a string that represents the name of the secret society. The name is created by concatenating the first letter of each friend's name, sorted in alphabetical order.

Note: Only use the map, filter, or reduce methods, or a combination of these methods, to solve the problem. Do not use loops to iterate or perform the operation.

Example 1

Input: createSocietyName(['Jack', 'Jill', 'John']);
Output: "JJK"

Example 2

Input: createSocietyName(['Tom', 'Jerry', 'Spike']);
Output: "JST"

Example 3

Input: createSocietyName(['Emma', 'Oliver', 'Ava', 'Liam']);
Output: "AELO"

Are you stuck on this problem?

Get detailed, step-by-step solution and improve your JavaScript skills.

  • Detailed Explanation: Each solution comes with a comprehensive explanation, helping you understand the logic and concepts thoroughly.
  • Learn to Write Better Code: Even if you have written the code, discover ways to improve it and adopt best practices.
  • Save Time: Don’t waste hours struggling—get the solution and learn efficiently.
  • Lifetime Access: Get access to lifetime solutions for all problems available
Get the Solution

" I struggled with this problem for hours, but the solution provided here was clear and easy to follow. It helped me understand where I went wrong and improved my coding skills significantly." - Jane D.

If you're not satisfied, I offer a 7-day money-back guarantee.