Functions

Contact Us or call 1-877-932-8228
Functions

Functions

Functions in JavaScript are more than just static blocks of code. They are Function objects that we can use just like any other data type value, e.g. we can pass functions to other functions, we can store a function in a variable, we can modify a function, etc.

We will discuss functions in detail later. For now let's just remember how we declare and call functions.

Code Sample:

QuickRecap/Demos/functions.html
---- C O D E   O M I T T E D ----

	//declare the function
	function sayHowMuch(name, price, quantity) {
		var finalPrice = price * quantity;
		alert('The price for ' + quantity + ' ' + 
		name + '(s) is $' + finalPrice);
	}
	
	//call the function with arguments
	sayHowMuch('ice cream cone', 1.99, 3);
	sayHowMuch('Movie ticket', 10.00, 5);
---- C O D E   O M I T T E D ----
Next