DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
jasman7799 profile image
Jarod Smith

// "enterprise" solution
function peelString(str = '')
{
  //validate
  if(typeof(str) != 'string')
    throw new Error(`${str}, ${typeof(str)} is not a string`);
  if(str.length <= 2)
    throw new Error(`${str} does not have atleast 3 letters`);

  // process
  return str.substring(1,str.length-1);
}

My "enterprise" solution