Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get the Middle Character

//codewars:Get the Middle Character
function getMiddle(str)
{
   let length = str.length
   if(length <=0 || !str)return ""
   if(length%2==0){

       var result = str.charAt(Math.floor(length/2)-1)+str.charAt(Math.floor(length/2))
   }else  var result = str.charAt(Math.floor(length/2))
        
   return result

}
 
PREVIOUS NEXT
Tagged: #Get #Middle #Character
ADD COMMENT
Topic
Name
8+7 =