Skip to content

Latest commit

 

History

History
56 lines (31 loc) · 649 Bytes

File metadata and controls

56 lines (31 loc) · 649 Bytes

Functions

/**
 * Declare a function
 */

function square(number) {
	return number * number;
}



/**
 * Use a function
 */

console.log(square(2));

var x = 3;
var y = square(x);
console.log(y);



/**
 * Declare and use a function with several parameters
 */

function sum(nr1, nr2, nr3) {
	return nr1 + nr2 + nr3;
}

var s = sum(2,4,6);
console.log(s);


Reference and read more

MDN function

Revision history

2014-06-03 (sylvanas) PA1 First try.