7/7 You deserved it! Why did CodeAcademy write these pieces?


#1


I passed this one but wonder what CodeAcademy tutor meant by adding || 0


var cashRegister = {
    total:0,
    lastTransactionAmount: 0,
    add: function(itemCost){
        this.total += (itemCost || 0);
        this.lastTransactionAmount = itemCost;
    },

and this .toFixed(2)

console.log('Your bill is '+cashRegister.total.toFixed(2)


#2

I still don't get (itemCost || 0). But toFixed(2) is how many digits you want after the dot.
.toFixed(2) = 13.74
.toFixed(3) = 13.744 (you can try and check)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.