string penambahan otomatis di 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')
Gorgeous Gazelle