Remove First and Last Character : codewars javascript

front·2022년 11월 9일

kata

It's pretty straightforward. 
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.

my answer

function removeChar(str){
 //You got this!
  var last_index = str.length -1
  var result = str.slice(1,last_index);
  return result
};

best answer

function removeChar(str) {
  return str.slice(1, -1);
}
profile
그냥 하기

0개의 댓글