+31

[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!:-)

5/16/2018 8:31:09 AM

Danijel Ivanović

33 Answers

New Answer

+29

My try 👇 https://code.sololearn.com/WyZ4EAaDQPu1/?ref=app

+19

https://code.sololearn.com/cJkjJ12YCWKs/?ref=app

+18

https://code.sololearn.com/c6nhF5Z8rx43/?ref=app

+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! 👍😉

+16

Kotlin oneliner 😉 https://code.sololearn.com/cP2ADjwgKj7P/?ref=app https://code.sololearn.com/cia9VCaBIEbV/?ref=app https://code.sololearn.com/cc1G4NQn0QL7/?ref=app https://code.sololearn.com/cN7P94XLLew6/?ref=app

+16

https://code.sololearn.com/cv7s1segzrVR/?ref=app

+14

pretty much the same as others solutions https://code.sololearn.com/cPJnv6Cqmls3/?ref=app

+12

https://code.sololearn.com/c8EIvSGVT563/?ref=app

+12

My try;😉 https://code.sololearn.com/clBMpeI7NB3y/?ref=app

+12

My try in JS: https://code.sololearn.com/Wd0mML1T8znr/?ref=app

+11

https://code.sololearn.com/cOomNTx8kfLr/?ref=app

+11

My Python-Solution: https://code.sololearn.com/cxzGCL5p4ARH/?ref=app

+10

Another pythoneliner https://code.sololearn.com/c42cvAa6AWbn/#py

+9

Easy One https://code.sololearn.com/cJTkUivxt80f/?ref=app

+9

Yeah, Luka will do it in one line 😁 Here is mine https://code.sololearn.com/c9hk0oOhzuC8/?ref=app

+8

My implementation https://code.sololearn.com/cxJ28Jr14DI1/?ref=app

+7

My code https://code.sololearn.com/cvWzuTi71fTU

+7

My try here https://code.sololearn.com/c3MQqSu5Vc32/?ref=app Note - The challenge has been updated. Earlier it didn't talk of space within the word but now it does ! My code does not handle space as of now.

+7

my python code https://code.sololearn.com/c9c7kgGb3ibW/?ref=app

+7

Python oneliner: https://code.sololearn.com/cVi7jKs1e7JL/?ref=app