简体   繁体   English

试图让我的输入值四舍五入到下两位小数

[英]trying to get my input values rounded off to next two decimals

Hi please help I am trying to get toFixed(2) don't know where I am going wrong嗨,请帮助我试图去固定(2)不知道我哪里出错了

function addFunction(item) {
            let cost = 0
            if (totalSettings < criticalLevel) {
                switch (item) {
                    case "call":
                        cost = callCost.toFixed(2);
                        totalSettings += callCost;
                        callTotalSettings += callCost;
                        break;
                    case "sms":
                        cost = smsCost.toFixed(2);
                        totalSettings += smsCost;
                        smsTotalSettings += smsCost;
                        break;
                }
                userMappedData.push({
                    type: item,
                    cost,
                    timestamp: new Date()
                })
                return true
            }
        }
function settingsBillTotals() {
            return {
                totalSettings.toFixed(2),
                callTotalSettings.toFixed(2),
                smsTotalSettings.toFixed(2)
            };
        }

please note settingsBillTotals() currently doesnt work thats where i thought i should put toFixed() i tried putting it on total settings but still wont work, my heroku app link https://settingsbillexpress.herokuapp.com/ if not sure what i mean请注意 settingsBillTotals() 目前不起作用 那我认为我应该把 toFixed() 我试着把它放在总设置上但仍然不起作用,我的 heroku 应用程序链接https://settingsbillexpress.herokuapp.com/如果不确定我的意思

let totalset = totalSettings.toFixed(2);
let callTotalset = callTotalSettings.toFixed(2);
let smsTotalset = smsTotalSettings.toFixed(2);
return {
    totalset,
    callTotalset,
    smsTotalset
        };
}```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM