Writing functions

To write a function you need to use this syntax.
function myFunction() {

}

You can write any code inside a function you want, but be careful!
In this version, variables are not scoped, so any variable you set inside this function is set everywhere.

To use function arguments, use this syntax.
function myFunction(argument) {...
The global scoping also applies to arguments, so name them carefully.

Table of contents

Previous: 1.1 User input
Next: 1.3 Control flow