Answers for "11.6.1.1. Functions Can Call Other Functions¶"

0

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.*/
Posted by: Guest on July-16-2021

Code answers related to "11.6.1.1. Functions Can Call Other Functions¶"

Code answers related to "Javascript"

Browse Popular Code Answers by Language