I have been learning javascript test scripts in Postman.Here I am just learning about callback functions and I wanted to check return value is showing in the last line of print statement but the result shows ‘undefined’. Below is the code:
function add(a,b)
{
console.log(a+b);
return a+b;
}
function test(testname,callbackfunction,m,n)
{
console.log(testname);
callbackfunction(m,n);
}
console.log
(test("THis is addition",add,12,12));
Console shows:
THis is addition
24
undefined
Why it showing undefined in the last line instead of showing 24 the return value?
Thanks in advance.
I tried to store the return value in a variable but it showing the same ‘unfined’ result.
let stu=test("THis is addition",add,12,12);