Answers for "function in js"

13

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
}
Posted by: Guest on September-05-2020
1

javascript function

function myFunction(){
  document.write("Hello World!")
}
myFunction();
Posted by: Guest on September-02-2021
8

js function

function name(parameter1, parameter2, parameter3) {
// what the function does
}
Posted by: Guest on January-04-2021
2

js function

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!
Posted by: Guest on June-22-2020
1

js function

var x = 10;

function créerFonction1() {
  var x = 20;
  return new Function("return x;"); // ici |x| fait référence au |x| global
}

function créerFonction2() {
  var x = 20;
  function f() {
    return x; // ici |x| fait référence au |x| local juste avant
  }
  return f;
}

var f1 = créerFonction1();
console.log(f1());          // 10
var f2 = créerFonction2();
console.log(f2());          // 20
Posted by: Guest on December-10-2020
0

function in js

function
name(parameter1, parameter2, parameter3) {

    // code to be executed

}
Posted by: Guest on July-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language