Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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')
 
PREVIOUS NEXT
Tagged: #auto #increment #string #javascript
ADD COMMENT
Topic
Name
9+2 =