Lesson 5: Calling Functions
Lesson 5: Calling Functions
So far, you've learned how to create constants and variables to store and use values, and how to make decisions in code using the if expression and decision operators like and and or.
So far, you've learned how to create constants and variables to store and use values, and how to make decisions in code using the if expression and decision operators like and and or.
Now it's time to learn how to write code that you can easily reuse in your program.
Remember from Lesson 2 that an expression is the smallest unit of code that produces a result? And that when an expression executes and outputs a value, that the value that it outputs is the result?
You can take advantage of this to make your code more efficient.
Expressions can be combined with other expressions to create functions, and functions can be used over and over in your code without having to rewrite what they do each time.
Using Expressions in Functions
A function (also referred to as a routine) is reusable code that provides instructions for performing an action, or for creating an output based on input.
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.