11.6.1.1. Functions Can Call Other Functions¶
/*Functions should only accomplish one (preferably simple) task. To solve
more complicated tasks, one small function must call other functions.*/
function addTwoToNumber(num){
return num += 2;
}
function addFiveToNumber(value){
let result = addTwoToNumber(value) + 3;
return result;
}
console.log(addFiveToNumber(12))
17
/*Of course, there is no need to write a function to add 5 to a value,
but the example demonstrates calling a function from within another
function.*/