Accessing a counter in a variable name in Javascript (code inside) -


I am trying to do something similar to the following PHP code but in javascipt:

   

After reaching the loop number basically, the following is messy with 0, if less than 10 but I do not know syntax in JS to do this: (

Sorry for the noob style

I think that you have zero to zero Instead a leading zero means ...

You can use conditional operators for example:

  (n <10 '' 0 ':' ') + N   

You can do a general question The function function also implements:

  function pad left (str, len, ch) {while (str.length & lt; len) str = ch + str; return str;}  For example:  
  var value = obj ['entry' + (n <10 '' 0 '')  

: '') + N + '_cash'];

If n contains 4 , then this Obj.entry04_cash .

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -