I need a JavaScript function to convert CM to IN. I have been using the following:
function toFeet(n) {
var realFeet = ((n*0.393700) / 12);
var feet = Math.f
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