kevin
0
Q:

function javascript

var x = myFunction(4, 3);     // Function is called, return value will end up in x

function myFunction(a, b) {
    return a * b;             // Function returns the product of a and b
}
3
// variable:
var num1;
var num2;
// function:
function newFunction(num1, num2){
	return num1 * num2;
}
2
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 myFunc(theObject) {
  theObject.make = 'Toyota';
}

var mycar = {make: 'Honda', model: 'Accord', year: 1998};
var x, y;

x = mycar.make; // x gets the value "Honda"

myFunc(mycar);
y = mycar.make; // y gets the value "Toyota"
                // (the make property was changed by the function)
1
function myfunction() {
  console.log("function");
};

myfunction() //Should say "function" in the console.

function calculate(x, y, op) {
  var answer;
  if ( op = "add" ) {
    answer = x + y;
  };
  else if ( op = "sub" ) {
    answer = x - y;
  };
  else if ( op = "multi" ) {
    answer = x * y;
  };
  else if ( op = "divide" ) {
    answer = x / y;
  };
  else {
    answer = "Error";
  };
  return answer;
};

console.log(calculate(15, 3, "divide")); //Should say 5 in console.
//I hope I helped!
1

function myFunction(p1, p2) {

    return p1 * p2;  
//  The function returns the product of p1 and p2

}

 
1
function myFunction() {
  alert("ALERT!");
}

myFunction();
1
function myFunction(var1, var2) {
  return var1 * var2;
}
3
function myFunc(param) {
  return param
}
console.log(myFunc("Hello World"))
0

New to Communities?

Join the community