|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
268 bytes
|
| Line | |
|---|
| 1 | function round(value, precision = 0) {
|
|---|
| 2 | if (!Number.isInteger(precision)) {
|
|---|
| 3 | throw new Error('Precision must be an integer.');
|
|---|
| 4 | }
|
|---|
| 5 | const multiplier = Math.pow(10, precision);
|
|---|
| 6 | return Math.round(value * multiplier) / multiplier;
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | export { round };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.