We frequently need to repeat a similar action throughout the script. The primary building blocks of the software are functions. They allow the code to be called several times without having to repeat it.
A function is created with a function keyword
function functionName(parameter1, parameter2, ... parameterN){
//code block
}
function add() {
console.log(2+3)
}
add();
5
function add(a,b) {
console.log(a+b)
}
add(3,5);
8
function add(a,b) {
return a+b;
}
const result = add(2,8);
console.log(result)
10