DEV Community

Discussion on: Daily Challenge #1 - String Peeler

Collapse
 
olragon profile image
Long Nguyen

Javascript

function removeFirstAndLast(txt) {
  if (typeof txt != "string" || !txt || txt.length < 2) {
    return null;
  }
  return txt.slice(1, txt.length - 1);
}