Tim K
0
Q:

how to use function in javascript

/* Declare function */
function myFunc(param) {
  // Statements 
}
2
function idk() {
	alert('This is an alert!')
}
//call the function to make the function run by saying "Name of function + ()"
idk()
5
A function is a reusable block of code that allows you to 
input specific values. To specify the values you need to call
the function by typing the name along with the desired values
spaced by commas.

function myFunction(value1, value2) {
	return value1 + value2;
}

myFunction(10, 5);




Now the function will return 15.
11
function myFunction(var1, var2) {
  return var1 * var2;
}
3

New to Communities?

Join the community