I'm adding up numbers using Javascript.
I tried using Number
and Parsfloat
but the number is returned is strange and long...
like 19.0000000
A simple working example is here:
https://jsfiddle.net/7kkqkuhw/
and this is my code:
$(document).on('click','.btn',function(e){
var price = $(this).attr('data-price');
var curPrice = localStorage.getItem('totalPrice');
var setPrice = Number(price) + Number(curPrice);
alert(setPrice);
});
Could someone please let me know what I am doing wrong?