Why Functions

Functions are a great tool for us for the following reason (and more):

  • Breaks down the code into smaller parts

    • Makes it easier to solve a problem when writing code, and easier to learn when reading code

  • Code reusability

    • Once we define a function and it works, we just need to call the function to get the results. This way we don't have to copy and paste code when want to do a task in multiple places

  • Keeps unnecessary details away from developer

    • Let's say you wrote a function that converts your weight from lbs to kg. If I were to use your function, I'll just call the function in one line. I don't need to see how you coded that function, by being able to call it I can just focus on my code and not think about yours

Last updated