Skip to content Skip to sidebar Skip to footer

Convert Centimeters To Inches Using Javascript

I need a JavaScript function to convert CM to IN. I have been using the following: The catch is it converts 100cm into 3'3'. I only deal in CM (australia) but from checking on con

Solution 1:

Your code is correct and gives the right result.

I would change it in the following way, so I am sure I do not lose precision using an approximate number for the conversion. This may be useless in your case, but sometimes could come into play (e.g. calculating distances on maps).

var realFeet = n / 30.48; // = 12 * 2.54

Post a Comment for "Convert Centimeters To Inches Using Javascript"