
Originally Posted by
NitroDev
Thanks traq and now i have a question is it possible to add multiple
Values on same variable on same function
I'm not quite sure what you mean by that.
You can provide a new value each time you call a function:
Code:
var hello = function( name ){
var greeting = "Hello, " + name + "!";
return greeting;
}
hello( 'World' ); // Hello, World!
hello( 'Adrian' ); // Hello, Adrian!
hello( 'NitroDev' ); // Hello, NitroDev!
Functions can also have more than one argument:
Code:
var add = function( num1, num2 ){
var sum = num1 + num2;
return sum;
}
add( 50,-8 ); // 42
Functions can even have unnamed arguments (though this concept is a little more advanced, and is not always as useful as it seems):
Code:
var mystery = function(){
var count = arguments.length;
var response = "You passed " + count + " arguments to this function.";
return response;
}
mystery( 'one arg' ); // You passed 1 arguments to this function.
mystery( 'a','b','c' ); // You passed 3 arguments to this function.
If you're asking something else, please explain further.
Bookmarks