Reported by: Bob from Accounting
The function in question is supposed to calculate the total cost of all items in the cart. However, it keeps spitting out the square root of the total cost instead.
When trying to calculate the total cost, the function returns: 4.472141212
When the correct total cost is: 20
We are not sure what sorcery is at play here.
Discuss this bug in the comments
function calculateTotal() {
return Math.sqrt(this.totalCost);
}
var totalCost = 20;
console.log(calculateTotal());