Please enable JavaScript to use CodeHS

CodeHS Glossary


Call a Function JavaScript

Calling a function actually gives the command, so the computer will run the code for that function. As opposed to [defining a function][1], calling a function actually runs code. In order to call a function, you must define it first, so the computer knows what to do. You can also refer to calling a function as "giving a function," "giving a command,"or "running a command." ---------- **Example in Karel** function start() { move(); turnRight(); // Calls the function } // Defines the function function turnRight() { turnLeft(); turnLeft(); turnLeft(); } ---------- When you just [define a function][2], it does not run any of the commands inside it, so you also need to call the function where you want the commands to actually run. [1]: http://codehs.com/glossary/term/11 [2]: http://codehs.com/glossary/term/11