+ 5

How can we pass the result of a function to a second function? In js

js

13th Feb 2017, 5:57 PM
Amin Al olofi
Amin Al olofi - avatar
2 Respuestas
+ 17
Just call the first function inside of the second one. function foo(){return 1+1;} function bar(){var i = foo();}
13th Feb 2017, 6:05 PM
Igor Makarsky
Igor Makarsky - avatar
+ 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.
2nd May 2017, 10:33 PM
Andrew Harchenko (Tomsk)
Andrew Harchenko (Tomsk) - avatar