Function Syntax
This code shows four different ways to create JavaScript functions.
HTML
<div id="output"></div>
JavaScript
function add(a, b) {
return a + b;
}
const addv2 = function(a, b) {
return a + b;
}
const addv3 = (a, b) => {
return a + b;
}
const addv4 = (a, b) => a + b;
const display = (html) => document.getElementById('output').innerHTML += html + '<br/>';
display(add(2,3));
display(addv2(22,3));
display(addv3(2,3));
display(addv4(2,3));