1var x = myFunction(4, 3); // Function is called, return value will end up in x
2
3function myFunction(a, b) {
4 return a * b; // Function returns the product of a and b
5}
1function myFunc(theObject) {
2 theObject.make = 'Toyota';
3}
4
5var mycar = {make: 'Honda', model: 'Accord', year: 1998};
6var x, y;
7
8x = mycar.make; // x gets the value "Honda"
9
10myFunc(mycar);
11y = mycar.make; // y gets the value "Toyota"
12 // (the make property was changed by the function)
13
1//(don't type behind the// type function to after that name it//
2function name() {
3 (name)=name
4 console.log(name)
5};
6//{ symbol is used o group together code but you must create n index/array of 2(array3)//
1function sayHelloTo(to) {
2 alert(`Hello ${to}`);
3}
4sayHelloTo('World from Grepper')
1function addfunc(a, b) {
2 return a + b;
3 // standard long function
4}
5
6addfunc = (a, b) => { return a + b; }
7// cleaner faster way creating functions!
8