Skip to content
Advertisement

Using the output of a function as an input of another function

Suppose i have function like this.

JavaScript

So is it possible for me to use the variable C outside in another function like this? Is this a correct way?

JavaScript

Advertisement

Answer

just use the returned value as a parameter

heres an example:

JavaScript

heres how it could apply to your case:

first off you’re only going to get one value from this since a cant be less than and greater than 5 at the same time, so im going to modify the function to give you both values as a tuple:

JavaScript

If you look closely, funA returns a tuple of those values so you can access each one using their index; first index is 0, and second index is 1 hence: funA(1,2)[0] and funA(1,2)[1]

Advertisement