TOC
wwworkshop
Uni Köln

3.6
Functions

Functions are containers for some code, which can then be executed multiple times. They are used to structure programs.

Functions can also take parameters, so they can be executed multiple times, but with different values.

Function example 1

function greet () {
    alert('hey')
    alert('you')
}

greet()
greet()

Function example 2

function greet (name) {
    alert('hey ' + name)
}

greet('you')
greet('everyone')