JavaScript Basics: How to return a value from a function in Vanilla JavaScript

Image for post
Image for post
function getMultiply(numberParam) {
console.log('Multiply', numberParam * numberParam);
}
getMultiply(7);

Return a value from the function

function getMultiply(numberParam) {
return numberParam * numberParam;
}
console.log(getMultiply(7));

How do you use the return statement?

Written by

I write stories about Frontend Dev, JavaScript, Typescript, Angular, NodeJS, Serverless Functions, JAM Stack, FaunaDB, Netlify, Apple, iOS— https://byrayray.dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store