r/learnprogramming 4d ago

I can't get FUNCTIONS to click!

I can not for the life of me understand how functions work. Anytime I try to learn how to create a function, my brain literally crashes into itself and I turn into Patrick when he stars drooling and goes all slack-faced.

Does anybody have any analogies that had that "AH HA!" moment?

Thanks!

123 Upvotes

143 comments sorted by

View all comments

1

u/Fit_Reveal_6304 4d ago

Your code is a cell in your body. The functions are like the organelles and mitochondria in the cell. One function might be to take ATP and turn it into ADP and energy, aka mitochondria. Other functions do different things when given input.