Your challenge today is to initialize an individual's middle name (if there is any).
Example:
'Jack Ryan' => 'Jack Ryan'
'Lo...
For further actions, you may consider blocking this person and/or reporting abuse
CSS
Wrap each word in a
span
, and add the class "mn" to the container.Live demo on CodePen.
I also did a JavaScript version on that same demo:
If you select-and-copy the names, the full name is copied instead of the shortened one.
Not the best solution: ))
Ruby solution
I just changed a few things in a similar function from singl.page. Doesn’t use join(). Works when only a single name is provided.
PHP Solution
Here's mine, with a more functional approach - also takes into account name strings that have erroneous spaces
jsbin.com/gedejih/edit?js,console
Javascript
This was fun :)
Python
JavaScript:
Here is the simple solution with Python:
Python.
I had two attempts at this, my first was only for full names up to three words but after realising I needed to expand the program to work on more I rewrote the program. Both and posted below and annotated.
First attempt
Second Attempt
I wasn't too happy on the result,
Any pointers on how to I could improve my code would be great!
But ey it works,
😁..I am uh, very, mature.
My solution in js
ruby <3
Python :
Nice,
Here's my Python solutions!
dev.to/teotcd/comment/e6fl