A pure function is a function that:
✅ Same input, same output
✅ No side effects
❌ Modifies an external variable (total
) → Side effect
❌ Does not always return the same result for the same input
✅ Predictability – Easy to test and debug.
✅ Referential Transparency – Can be replaced with their output without changing behavior.
✅ Avoids Side Effects – Safer for functional programming.
✅ No external state changes
✅ Always predictable
Would you like a real-world use case for pure functions? 🚀