how to write function javascript code example
Example 1: simple javascript function
function idk() {
alert('This is an alert!')
}
idk()
Example 2: define function in javascript
function myFunc(param) {
}
Example 3: functions in javascript
function myFunction(var1, var2) {
return var1 * var2;
}
3
How to create a function in javascriptJavascript By TechWhizKid on Apr 5 2020
function addfunc(a, b) {
return a + b;
}
addfunc = (a, b) => { return a + b; }
Example 4: how to write a function javascript
function name(argument){
return argument + 2
}
name(4)
let name = function(arg){ return arg + 2}
name(4)
let name = (arg) => {return arg+ 2}
name(4)