Your task is to write a function loneliest() which accepts a string and will return the character that has the most spaces to its right and left.
Examples
'a b c'
=> ['b']
'a bcs d k'
=> ['d']
' a b sc p t k'
=> ['p']
'a b c de'
=> ['b', 'c']
' a b c de '
=> ['b']
'abc'
=> ['a', 'b', 'c']
Tests
loneliest('abc d ef g h i j ')
loneliest('abc')
loneliest(' abc d z f gk s ')
Good luck!
This challenge comes from aplefull on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!