← Back to challenges

Initialize

JavaScriptHardarraysformatting

Instructions

Create a function that takes in an array of full names and returns the initials.

Examples

initialize(["Stephen Hawking"]) ➞ ["S. H."]

initialize(["Harry Potter", "Ron Weasley"]) ➞ ["H. P.", "R. W."]

initialize(["Sherlock Holmes", "John Watson", "Irene Adler"]) ➞ ["S. H.", "J. W.", "I. A."]

Notes

  • Each initial is followed by a dot.
  • Names will always be made of two words, separated by a space.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.