Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Remove First and Last Character

// Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less than two characters.

function removeChar(str){
  const strLength = str.length
  if(strLength < 2) return str
  
  return str.substr(1, strLength - 2)
};

// With love @kouqhar
Source by www.codewars.com #
 
PREVIOUS NEXT
Tagged: #Remove #First #Last #Character
ADD COMMENT
Topic
Name
4+4 =