Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMahmoud Talass
9,274 PointsMath.round
isn't it better to use Math.round instead of Math.floor and Math.ceil?
2 Answers
Unsubscribed User
Front End Web Development Techdegree Student 33,900 PointsHi Mahmoud,
it depends on what you want to do...
The Math.round() returns the value of a number rounded to the nearest integer.
The Math.floor() function returns the largest integer less than or equal to a given number.
The Math.ceil() function always rounds a number up to the next largest integer.
Those produce different results and depending on what you need you have to use the appropriate function.
Makes sense?
Blessings from Berlin, Nils
Mahmoud Talass
9,274 PointsYes, thank you!