N
N
Nubbin2017-11-15 18:23:58
typescript
Nubbin, 2017-11-15 18:23:58

Typescript toFixed?

Good evening.
There is a price: 102.9385

let price = 102.9385;
console.log(price.toFixed(2)); // Результат: 102.94

How to make "toFixed" not round but simply cut off the last 2 characters from the end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2017-11-15
@Taraflex

let price = 102.9385;
console.log(~~(price*100)/100);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question