Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level 11 Lesson 4 - callback function , need parameter definition , please help


function multiply(val1, val2, callback)
{
// find result of multiplication
let result = val1 * val2;
callback(result);

}

function display(result)
{
console.log("Result: " + result);
}

// call the function

multiply(2, 4, display);
by

10 Answers

Sanju3399
this code i got answer result:8 but it not accepting bro
Sanju3399
function multiply(val1,val2,displayResult)
{
// find result of multiplication
let result = val1 * val2;
displayResult(result);

}

function display(result)
{
console.log("Result: " +result);
}

// call the function
multiply(2,4,display)
Sanju3399
try this code once
SaravananRajendran
Above you mentioned code is working bro , but as per the task we need to use callback function in the name of callback but i dont knw y that was not accepting ... but this display result got worked :)
Sanju3399
Bro what was wrong in my code should I need to change "result" to "displayResult"?
And to use callback function right
Sanju3399
Can u tell me what should I need to change
Sanju3399
I was asking provide parameter to the multiple function definition!?
SaravananRajendran
No need to change dude , actually they asked us to pass callback function as parameter to execute the display function , but when i referred most of the google pages and tutorials it mentioned as in the name of callback so that i used the same name but thrown me error but u used the same displayResult name as parameter it got worked simple :)
Sanju3399
yes................ Tq bro i got it.
SaravananRajendran
Hi bro Level 11 , lesson 7 - regarding cookies i have posted in forum already please try to look into it

Login / Signup to Answer the Question.