Section 1 - Instruction

Last time, we learned how functions can receive information through parameters. But what if we want a function to give us information back after it's done working?

Engagement Message

Imagine asking a calculator to add numbers—wouldn't you want the answer back?

Section 2 - Instruction

Functions can return values using the return keyword. When a function returns something, it sends that value back to wherever the function was called from. The return keyword immediately stops the function's execution.

Engagement Message

What do you think this function gives back?

Section 3 - Instruction

To capture what a function returns, we assign the function call to a variable. The returned value gets stored in that variable for us to use later.

Engagement Message

See how we "caught" the returned value?

Section 4 - Instruction

Not all functions need to return values. A function that just prints a message, like our sayHello() function, doesn't need to send anything back. These are often used for performing an action.

Engagement Message

Can you spot the difference in how these might be used?

Section 5 - Instruction
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal