+ 5
How can we pass the result of a function to a second function? In js
js
2 Réponses
+ 17
Just call the first function inside of the second one.
function foo(){return 1+1;}
function bar(){var i = foo();}
+ 6
But he is asking how to _pass_ the result to a second function so I think it is about this way:
function foo() {
return 1+1;
}
function bar(arg1) {
return arg1 * 5;
}
alert(bar( foo() ));
//the "alerted" result is 10
//...and we passed twice. The result of a foo() was passed to bar() and then result of bar was passed to an alert() function.