Question: undefined 8. a. Create a script that has a function named foo which takes two parameters ('argl' and 'arg2'). Inside the function the parameters should
undefined
8. a. Create a script that has a function named foo which takes two parameters ('argl' and 'arg2'). Inside the function the parameters should be respectively assigned to two local variables ('varl' and 'var2'). The function should also define an inner function named bar (with no parameters) which displays Sum of parameters: followed by the sum of the two variables local to foo. Have a function call to bar from within foo, but after its function definition. Then outside the definition of foo, call foo with two integer arguments. Then try two floating point arguments, and then two strings arguments, two boolean arguments. b. Re-factor 8a to demonstrate the use of a closure (refer lecture notes 2a). The function bar (in foo) should be set to return, and its call from within foo is deleted. Then outside the definition of foo, call function foo with two arguments and assign it to another variable foo2; then call foo2. Think carefully about what this exercise is demonstrating
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
