gpt4 book ai didi

javascript - 不确定我的简单代码有什么问题

转载 作者:太空宇宙 更新时间:2023-11-04 06:06:09 26 4
gpt4 key购买 nike

我不确定自己在简单的销售税计算器中做错了什么。当我按下提交时,我想要显示一美元的商品成本加上销售税,但我看到的却是 total tip $functionround(){[native code]}

  //calculation
var total = (itemCost * salesTax + itemCost);

total = Math.round

最佳答案

total = Math.round

在上面的行中,您将函数 Math.round 的值分配给变量 total。相反,您可能希望将函数 Math.round 返回的值分配给 total 变量,如下所示:

total = Math.round(total)

关于javascript - 不确定我的简单代码有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56844254/

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