11 lines
455 B
JavaScript
11 lines
455 B
JavaScript
var n1 = '$40.24';
|
|
var n2 = '$21.57';
|
|
var regp = /[^0-9.-]+/g;
|
|
|
|
console.log(parseFloat(n1.replace(regp, '')) + parseFloat(n2.replace(regp, '')));
|
|
|
|
console.log(parseFloat(n1.replace(regp, '')) - parseFloat(n2.replace(regp, '')));
|
|
|
|
console.log(parseFloat(n1.replace(regp, '')) * parseFloat(n2.replace(regp, '')));
|
|
|
|
console.log(parseFloat(n1.replace(regp, '')) / parseFloat(n2.replace(regp, '')));
|