[자바스크립트로 구현한 알고리즘] Get the Middle Character

남양주개발자

·

2016. 9. 18. 16:33

728x90
반응형


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.

Examples:

Kata.getMiddle("test") should return "es"

 

Kata.getMiddle("testing") should return "t"

 

Kata.getMiddle("middle") should return "dd"

 

Kata.getMiddle("A") should return "A"

Input

A word (string) of length 0 < str < 1000

Output

The middle character(s) of the word represented as a string.


 



728x90
반응형

💖 저자에게 암호화폐로 후원하기 💖

아이콘을 클릭하면 지갑 주소가자동으로 복사됩니다

0개의 댓글