?: doesn't work correctly in javascript -


i written following code change numbers persian:

function farsi(x) {     x = x.tostring().replace(/\b(?=(\d{3})+(?!\d))/g, ",");     var = '۰۱۲۳۴۵۶۷۸۹'; var b = '';      (var = 0; < x.length; i++) {          var c = x.charcodeat(i);          b += (c >= 48 || c <= 57 ? a.charat(c - 48) : x.charat(i));      }      return b;  } 

i have used regex thousand seprator how print number commas thousands separators in javascript works correctly. separator character not being added in line of code:

b += (c >= 48 || c <= 57 ? a.charat(c - 48) : x.charat(i)); 

here fiddle

you put || instead of &&

b += (c >= 48 && c <= 57 ) ? a.charat(c - 48) : x.charat(i); 

see working code https://jsfiddle.net/4qvwzs5e/2/


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -