i have the following arr with many objects inside . as a Following Exemplo:
var availableCost = [{cost: " $200"}, {cost: " $100"}]; //(every checkbox has saved as an Object
sumCosts = availableCost.reduce((s, o) => s+ +o.cost.match(/[\d.]+/), 0);
//if i do like this and then i check one checkbox, it will sum all values in this case $200 + $100 = 300
i tried already with for…in
Now, what i want to do with this is: for every checkbox checked == true, get this value. Just the currently checked Checkbox value(in this case value is the label: $100<label><input type="checkbox" name="js-libs"> $100</label>
)
i want to get that numbers to sum and display the total amount later.