Price
Usage
var { amount, formatted } = new Price(100.5);
console.log(amount); // 100.5
console.log(formatted); // 100.50
var { amount, formatted } = new Price('100.50 kronor');
console.log(amount); // 100.5
console.log(formatted); // 100.50 kronor
var { amount, formatted } = new Price({
amount: 100.5,
formatted: '100.50 kronor'
});
console.log(amount); // 100.5
console.log(formatted); // 100.50 kronor
Parameters
| Name | Type |
|---|---|
| value | Number | String | Object |
If a number is passed to Price, it will auomatically set the formatted property.
If a string is passed to Price, it will try to parse the amount property.
Passing an object with amount and formatted is recommended.
Example: new Price({amount: 100.5, formatted: '100.50 kronor'});