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

问题描述

您好,请帮助我尝试修复(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)
            };
        }

请注意settingsBillTotals()当前不起作用,多数民众赞成在我认为我应该放到Fixed()的地方 我尝试将其设置为总设置,但仍然无法正常工作,如果不确定我的意思,我的heroku应用程序链接https://settingsbillexpress.herokuapp.com/

解决方法

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