Stephan van Hulst wrote:Nope. When does a function call have a return value?
Stephan van Hulst wrote:
What do you need to do to make the function call evaluate to the number 3?
pramod talekar wrote:It should have return 3;
pramod talekar wrote:1.As each function has its own execution context and as getName() has only declarative statements and not expressions, why does the alert statement displays 'undefined' instead of Welcome Molly ?
2. Even if I move the return statement down, it doesn't change the outcome.
3. If I move getName() out of greetUser(), only then it works, but then even greetUser() is a part of greeting() and it can access it's parent's variables viz. time, then what is so different about getName()?
pramod talekar wrote:Another point is that, if I move getName() outside greetUser(), even then greeting() won't have any return statement, then why does 'Welcome Molly'appear instead of undefined?