I was wondering how to use parseFloat with a string?. Example:
var N = 3.43;
var M = 43.37;
var subtotal = N + M;
subtotal=parseFloat("subtotal");
I was wondering how to use parseFloat with a string?. Example:
var N = 3.43;
var M = 43.37;
var subtotal = N + M;
subtotal=parseFloat("subtotal");
You don't need parseFloat
in your case.
To use parseFloat
on a variable:
subtotal = parseFloat(subtotal); // No quotes here
Example:
var value = "3.14"; // String
var PI = parseFloat(value); // Float
OR
var PI = Number(value); // Float
OR
var PI = +value; // Float
Remove the quotes that you are passing inside parsefloat
.
var N = 3.43;
var M = 43.37;
var subtotal = N + M;
subtotal=parseFloat(subtotal);