Get the Middle Character – CodeWars’ Kata

You are going to be given a word. Your job 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.

Codewars

Pseudocode

getMiddle(word of type string) 
  len = word.length
  return word.split((len-1) / 2, len / 2)

Kotlin Implementation

chevron_left
chevron_right

Leave a comment

Your email address will not be published. Required fields are marked *

Comment
Name
Email
Website