So lets consider JavaScript language.When I clarify my intent as basePrice being const, why should I be re-calcualting basePrice again and again unless the quantity is going to change(which I hope not).
calculateTotal() { const basePrice = basePrice(); if (basePrice > 1000) { return basePrice * 0.95; } else { return basePrice * 0.98; } } basePrice() { return quantity * itemPrice; }
Customer support service by UserEcho
So lets consider JavaScript language.
When I clarify my intent as basePrice being const, why should I be re-calcualting basePrice again and again unless the quantity is going to change(which I hope not).