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 trialJaime Serradell
3,350 PointsCan I use parseInt instead parseFloat for this exercise? Is correct anyway?
The teacher use parseFloat to convert a number from a string. Is it correct to use parseInt instead parseFloat like the teacher uses?
2 Answers
Steven Parker
231,248 PointsThe correct conversion depends on what the number you are converting represents. For example, if the number is how many seats are at a table, "parseInt" would be the best choice. But if the number is the exact weight of a package in pounds, then "parseFloat" would be the right choice.
In the video, since the value is for generic math, "parseFloat" is a good choice because it applies the least constraint on the input value.
Jaime Serradell
3,350 PointsUnderstood! Thank you Steven!