JavaScript · Junior · Pytanie 67 z 75
Co zwraca Math.round(-2.5)?
- ✓Poprawna odpowiedź:
-2 - 2
-3 - 3
-2.5
Wyjaśnienie
Math.round zaokrągla .5 w stronę +∞, więc Math.round(2.5) to 3, a Math.round(-2.5) to -2. Gdy potrzebujesz innych reguł, użyj Math.trunc, Math.floor lub Intl.NumberFormat.