Answers for "js function"

5

simple javascript function

function idk() {
	alert('This is an alert!')
}
//call the function to make the function run by saying "Name of function + ()"
idk()
Posted by: Guest on May-08-2020
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
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

js function

function MyFunction() {
	/* Function Here */
}
Posted by: Guest on December-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language