1// 3 ways you see it
2function name(argument){
3 return argument + 2
4 //return something here
5}
6name(4) // equals 6
7
8let name = function(arg){ return arg + 2}
9name(4) //this equals 6, here we are calling our name function
10
11//es6 style
12
13let name = (arg) => {return arg+ 2}
14name(4) //equals 6
1function myFunction(var1, var2) {
2 return var1 * var2;
3}
43
5How to create a function in javascriptJavascript By TechWhizKid on Apr 5 2020
6function addfunc(a, b) {
7 return a + b;
8 // standard long function
9}
10
11addfunc = (a, b) => { return a + b; }
12// cleaner faster way creating functions!
1// Code by DiamondGolurk
2// Defining the function
3
4function test(arg1,arg2,arg3) {
5 // Insert code here.
6 // Example code.
7 console.log(arg1 + ', ' + arg2 + ', ' + arg3)
8}
9
10// Running the function
11
12test('abc','123','xyz');
13
14// Output
15// abc, 123, xyz