Following is my code to find the total amount in cash register. I am trying to change the type of total to floating point number using parseFloat but it’s not working. Can someone help me to understand how can i change the type of total to be floating point number.
let total = cid.reduce( (sum, elem) => (sum + elem[1]),0 );
total = parseFloat(total).toFixed(2);
When i run
console.log(typeof total)
it outputs string instead of int