JavaScript

toFixed & number formatting

Në shqip: Formatimi i numrave në JS

ShpjegimiSQ

toFixed(2) e rrumbullakos numrin në dy shifra pas presjes (si tekst). Për formatim sipas vendit (1.234,50 €) përdor toLocaleString("sq-AL") ose Intl.NumberFormat.

EnglishEN

toFixed(2) rounds the number to two decimals (as a string). For locale formatting (1.234,50 €) use toLocaleString("sq-AL") or Intl.NumberFormat.

Si ta mendosh

Si ta shkruash çmimin bukur në etiketë.

Lexoje në anglisht

Like writing the price neatly on a label.

Shembull kodijavascript

(8.456).toFixed(1);                    // "8.5"
(1234.5).toLocaleString("de-DE");       // "1.234,5"

Terma të lidhur