Part 3: Creating Functions for an Automatic Light Application

Learn about the possible ways of returning values from a function.

We'll cover the following

Returning values from a function

We have previously created a function, but now we must check whether this function needs to return something. It calculates the distance, which we need to be outside of the function—so that value needs to be returned.

Again, we have two options. We can either return the value contained inside the variable distance like this:

Get hands-on with 1400+ tech skills courses.