Published in: JavaScript
function roundCents(amount) { cents = amount * 100; cents = Math.round(cents); str = "" + cents; len = str.length; return str.substring(0, len - 2) + "." + str.substring(len - 2, len); }
You need to login to post a comment.
Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.
ecavazos on 01/22/08
Published in: JavaScript
function roundCents(amount) { cents = amount * 100; cents = Math.round(cents); str = "" + cents; len = str.length; return str.substring(0, len - 2) + "." + str.substring(len - 2, len); }
You need to login to post a comment.