Slide 1 / 15
Why use functions?
A function is a named block of statements that does one specific job. Instead of writing the same code multiple times, you write it once as a function and call (use) it wherever you need it.
Benefits:
- Reusability — write once, use many times
- Readability —
calculateArea(5)is clearer than 10 lines of math - Easier debugging — fix a bug in one place, fixed everywhere
- Teamwork — different people can write different functions