zwei1121

<script>
function percentage(ary, lth) {

var s = \'\';
for (var i = 0; i < ary.length; i++) with (Math)
s += round(parseInt(ary[i]) / parseInt(eval(ary.join(\'+\'))) * 100 * pow(10, lth)) / pow(10, lth) + \'%;\';
return s.split(\';\');
}
alert(percentage([1250, 50, 3, 25, 612], 3).join(\'\n\'));
var s1 = Math.round(7 / 30 * 100 * Math.pow(10, 2)) / Math.pow(10, 2) + \'%\';
alert(s1);

</script>

分类:

技术点:

相关文章: