Linked Questions

Popular Questions

How to sum jquery map values

Asked by At

I have map function to get selected checkboxes and I need to sum values of this map but I get NaN


var prices = $("input:checkbox:checked").map(function(){
  return $(this).val();

var number = prices;
var nf = new Intl.NumberFormat('en-US', {
var formattedNumber = nf.format(number);

$('.paybutton').append('<a class=" btn-link" href="">'+ nf.format(prices)+'</a>');

console.log(prices); returns data below when i play with check boxes so i guess my map is OK.

Array [ "5467457" ]
Array [ "57558", "5467457" ]
Array [ "57558" ]
Array []

In other hand my appended data is like:


And it keeps this way as long as i play with check boxes.


  1. How can I have sum of my function in + nf.format(prices)+?

Related Questions