gpt4 book ai didi

javascript - 我想得到小数点后两位的结果

转载 作者:行者123 更新时间:2023-12-01 02:54:06 25 4
gpt4 key购买 nike

下面是我当前使用的代码,我需要将最终结果四舍五入到小数点后两位。有人可以帮我找出我做错了什么吗?

total = panjang*ht+hf;
document.getElementById("ototal").innerHTML =eval(total(toFixed(2)));

最佳答案

变量total是一个数字,而不是函数。您应该使用像这样的 toFixed 函数

total.toFixed(2)

关于javascript - 我想得到小数点后两位的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46821854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com