Click here to Skip to main content
15,075,944 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
// finds age
	function findAge(dob) {
	   var personAge = 2018 - dob;
	   return personAge;
	   var ageMike = findAge(1990);
// function calling function 		
	function retirementCheck(year) {
	   var age = findAge(year); 

          /*1. how this function call findAge(year) is working?
         2. previous function block code runs inside this function?
	3. gets reference or copy or just go to that function and generate output 
            and return to this function?
	4. Is a previous block
	var personAge = 2018 - dob;
	return personAge;

         dob changed to year because i have year 
         parameter now?

	var retirement = 65 - age;

What I have tried:

I want to know how a called function is working inside another function and how parameter is working
Updated 2-Jun-18 2:53am
Gerry Schmitz 3-Jun-18 13:20pm
What happens when someone is "older" than 65? Pension? Retirement? App goes crazy? All of the above?

1 solution


This calls the function retirementCheck passing the value 1994. The retirementCheck function refers to that value by the parameter name year. It then calls the findAge function passing in the year value. The findAge function calculates the age and returns it to the calling function.

You can find full details in any Javascript book or tutorial.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900