function foo() {
for (var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
foo(1,2,3);
//1
//2
//3
// program to print the text
// declaring a function
function greet(name) {
console.log("Hello " + name + ":)");
}
// variable name can be different
let name = prompt("Enter a name: ");
// calling function
greet(name);
function name(param, param2, param3) {
}
function add() {
var sum = 0;
for (var i = 0, j = arguments.length; i < j; i++) {
sum += arguments[i];
}
return sum;
}
add(2, 3, 4, 5); // 14
function hello(name) {
alert("Hello " + name);
}
var name = "Person";
hello();
An Example of a function argument
function printValue(someValue) {
console.log('The item I was given is: ' + someValue);
}
printValue('abc'); // -> The item I was given is: abc