Answers for "How to create a function in javascript"

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
3

javascript function

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)
Posted by: Guest on October-15-2020
12

declare function javascript

function myFunction(var1, var2) {
  return var1 * var2;
}
Posted by: Guest on February-05-2020
2

javascript functions

function sayHelloTo(to) {
  alert(`Hello ${to}`);
}
sayHelloTo('World from Grepper')
Posted by: Guest on October-03-2020
1

how do you create a function js?

//(don't type behind the// type function to after that name it//
function name() {
  (name)=name
  console.log(name)
};
//{ symbol is used o group together code but you must create n index/array of 2(array3)//
Posted by: Guest on January-02-2021
3

How to create a function in javascript

function addfunc(a, b) {
  return a + b;
  // standard long function
}

addfunc = (a, b) => { return a + b; }
// cleaner faster way creating functions!
Posted by: Guest on April-04-2020

Code answers related to "How to create a function in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language