A return value is the data that a function sends back to the code that called it. It can be any valid data type such as numbers, strings, booleans, or even objects.
To return a value from a function, we use the
return keyword followed by the value or expression we want to return. Once a return statement is executed, the function immediately stops executing and sends the value back to the caller.
Return values can be assigned to variables, used as inputs for other functions, or simply logged to the console for display. They provide a way for functions to communicate data back to the code that called them.
A function can have multiple return statements, but only one of them will be executed. The first return statement encountered in the function's execution path will be the one that sends the value back.
addNumbers function, add a return statement that returns the value of the
Sign up to start coding
Already have an account?