logo
Search
showing results for - "auto increment string in javascript"
Esteban
28 Apr 2016
1function autoIncrementCustomId(lastRecordId){
2  let increasedNum = Number(lastRecordId.replace('ABC','')) + 1;
3  let kmsStr = lastRecordId.substr(0,3);
4  for(let i=0; i< 6 - increasedNum.toString().length; i++){
5    kmsStr = kmsStr+'0';
6  }
7  kmsStr = kmsStr + increasedNum.toString();
8  console.log(kmsStr);
9}
10
11autoIncrementCustomId('ABC009999')
similar questions
add leading spaced in string javascriptjs increment and decrement function for carttruncate string in javascriptjavascript pre increment and post incrementjavascript pad string leftjs increment safety value htmldecrement operator in javascriptjs decrement for loopstring padding in javascripthow to truncate string in javascripttruncate a string using javascriptjquery increment value by 1javascript how to increment by other than one in for loopauto increment in realtime database with javascriptjavascript text auto writingjavascript decrementjavascript truncate stringauto type text javascriptfor loop decrement javascripthow to increment variable value in javascriptautogenrate 12 characters javascript
queries leading to this page
auto increment string in javascriptincrement in the last integer indexof string in javascriptsincrement in the last integer indexof string in javascriptauto increment string in javascript
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue