Answer and Explanation:
Subprograms are nested three deep hence we would have three subprograms/functions under one program(function)
We call the program/function MotherFunction( using camel case variable naming rules)
function MotherFunction() {
var mother= 8;
console.log(mother);
function subDaughter1() {
var subDaughter1X = mother + 12;
console.log(subDaughter1X);
function subDaughter2() {
var subDaughter2X= mother + 5;
console.log(subDaughter2X);
function subDaughter3() {
var subDaughter3X= mother + 3;
console.log(subDaughter3X);
alert("sum="+subDaughter1X+subDaughter2X+subDaughter3X);
}
}
}
}
MotherFunction();
We created the first function and nested subfunctions under it, adding up the variable from the parent function(mother function) to its subfunctions and then alerting the total value of all the subfunction variables summed in the last/third subfunction. We then called the function after defining it.