I asked my friend what a function is and what he told me wasn't really a good example, Any help?
Functions can be confusing from a conceptual standpoint. These analogies may help you.
A function as a subroutine - You can think of a function as a "subroutine" a block of code that can be executed again and again. Why do we want this? Because it reduces copying and pasting.
function YouCanRepeatMe() print("Hi.!") print("I like saying hi!") print("Hi there!") end YouCanRepeatMe() YouCanRepeatMe() YouCanRepeatMe() YouCanRepeatMe()
You can see here, that, instead of repeating the lines inside of the function 12 times, you can repeat it only 4 times, each time you call it. This is a subroutine. You gave it a name, YouCanRepeatMe, and you told it what to do. Programming is all about automating repetitive tasks! I'm sure you can divide 234.351 to 23.1225234, but it's much easier to type it into a calculator! That's what this is all about!