Last active
March 7, 2017 04:27
-
-
Save calthoff/dad6d462bfe4458a12a0f6ad711525f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMiddle(s){ | |
var m = s.length / 2 | |
if (s.length % 2 == 0){ | |
return s.slice(m - 1, m + 1) | |
} | |
return s.slice(m, m + 1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment