DEV Community

loading...

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);
}
Forem Open with the Forem app