0

Applying number format on dropdown appended array

arr = jQuery.parseJSON(data); <br>
                  for(i=0;i<arr.length;i++){<br>
                     $("#input_car_model").append(new Option(arr[i]['model']+" ("+arr[i]['cnt']+" 대)", arr[i]['model']));
                  }

Hello, I have a question about number_format
This part "arr[i]['cnt']" is number, and i want it to be shown like 100,000.
How can I apply number_format in this case?
Thank you!

Genish Parvadia
  • 1,437
  • 3
  • 17
  • 30

1 Answers1

0

I have created the same scenario and it worked for me. Check below code

var t = {1: [100000]};
t.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'); // gives "100,000.00"
pravindot17
  • 1,199
  • 1
  • 15
  • 32