+ 33

[ ASSIGNMENT: ] Get the Middle Character

TASK : You are going to be given a word. Your task is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters. For Example :: getMiddle("happy") --> return "p" getMiddle("codings") --> return "i" getMiddle("SoloLearn") --> return "L" getMiddle("playground") --> return "gr" NOTE : Spaces are ignored! #Output : The middle character(s) of the word represented as a String! HappyCodings!:-)

16th May 2018, 8:31 AM
Danijel Ivanović
Danijel Ivanović - avatar
30 Answers
17th May 2018, 4:33 PM
🌛DT🌜
🌛DT🌜 - avatar
+ 20
https://code.sololearn.com/cJkjJ12YCWKs/?ref=app
16th May 2018, 3:17 PM
Danijel Ivanović
Danijel Ivanović - avatar
17th May 2018, 9:18 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 17
The task is updated for the reason that you are taking the white space as part of a word! If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters. --> Spaces are ignored! Thank you all! 👍😉
16th May 2018, 6:04 PM
Danijel Ivanović
Danijel Ivanović - avatar
16th May 2018, 9:54 PM
MeanMachine
MeanMachine - avatar
+ 15
pretty much the same as others solutions https://code.sololearn.com/cPJnv6Cqmls3/?ref=app
16th May 2018, 10:44 AM
jay
jay - avatar
4th Jun 2018, 10:40 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 11
https://code.sololearn.com/cOomNTx8kfLr/?ref=app
16th May 2018, 8:46 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
16th May 2018, 10:09 PM
Cépagrave
Cépagrave - avatar
+ 10
Yeah, Luka will do it in one line 😁 Here is mine https://code.sololearn.com/c9hk0oOhzuC8/?ref=app
16th May 2018, 9:29 AM
voja
voja - avatar
16th May 2018, 8:49 AM
ᏳoƊoԲᎮc !
ᏳoƊoԲᎮc ! - avatar
16th May 2018, 10:42 AM
cyk
cyk - avatar
16th May 2018, 1:43 PM
John Wells
John Wells - avatar
16th May 2018, 5:11 PM
tamaslud
tamaslud - avatar
16th May 2018, 6:42 PM
Nevfy
+ 4
https://code.sololearn.com/c4oO0hP1SvZp/#py
16th May 2018, 12:03 PM
Lamkerian Sorbol
Lamkerian Sorbol - avatar
+ 4
16th May 2018, 3:56 PM
M. Wood
17th May 2018, 4:37 AM
李立威