JavaScript concept with a cup of coffee and a laptop

Function Return

We have sent values to a function, but what about getting information back? All functions return to the location from which they are called and they return data using the “return” keyword. If you do not use the “return” keyword, the function will return “undefined”.

function add( num1, num2 ) {
    let newNum = num1 + num2;
    return newNum;
}
let addSum = add( 1, 2 ); // Variable to hold function call. Allows ease of use.
console.log( addSum ); // Displays 3

Happy Coding!

Clay Hess

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email
Skip to content