Putting this in a function means that you canâ€™t just take the returned value out - to the computer, minV & maxV are undefined variables. Therefore, we encounter the problem of, how do we find the total of maxV & minV without pulling them out of the function and causing an error? We simply return implicitly, which is the total of maxV & minV! Oh and remove the if statement:

I think youâ€™ll be able to figure out the rest in terms of saying the value.

If you want to read further into the return statement (as it can actually get really confusing) you could bookmark this page so that you can get grips with it.

Hope this helps.

Tip: you can return multiple values in one statement by separating them with commas: return x, y, z

Remember, donâ€™t say a variable outside of a function or the computer will interpret that as an undefined variable. Try using the function itself. And remember to hightail it out of that canyon - Iâ€™ve heard witches lurk in thereâ€¦

So letâ€™s recap what I mean: any variables declared in a function cannot be called outside of it because its scope (where the variable can be used) does not reach that far. This is why you get this error:

If you try to use minV outside the function then the computer will think that you have used a variable that has not been defined. To solve this problem, say the function. Why? This return statement:

returns number which means that this function finds the sum of the lowest and highest trap values and returns it. So this must mean that if we said the function, we would really be saying the sum of the lowest and highest trap values. This is why you mustnâ€™t say the variable number, but the function. Do you understand now?