DEV Community

mcwhopper63
mcwhopper63

Posted on

What is a function in coding? explained by a semi-layman

What is a function?

Functions are tools.

🔨 I need to hammer a nail. The hammer is a tool. The hammer is a function. I expect the nail to be hammered with this tool / function.

🥣 I need to eat cereal. The spoon is a tool. The spoon is a function. I expect to eat my cereal with this tool / function.

🏠 I need to calculate my mortgage. The mortgage calculator is a tool. The mortgage calculator is a function. I expect to calculate my monthly mortgage payments with this tool / function.

Functions are tools.

We decided to become programmers to solve problems, no matter the size. Every problem can be broken down to smaller problems. And for every problem, we can create our own tools to solve them. That is the power of programming -- creating our own tools to tackle the problems we want to fix. Amazing stuff!

Top comments (0)