Answers for "auto increment string in javascript"

0

auto increment string in javascript

function autoIncrementCustomId(lastRecordId){
  let increasedNum = Number(lastRecordId.replace('ABC','')) + 1;
  let kmsStr = lastRecordId.substr(0,3);
  for(let i=0; i< 6 - increasedNum.toString().length; i++){
    kmsStr = kmsStr+'0';
  }
  kmsStr = kmsStr + increasedNum.toString();
  console.log(kmsStr);
}

autoIncrementCustomId('ABC009999')
Posted by: Guest on November-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language