Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 3, 2023 15:19
Show Gist options
  • Save suhailgupta03/3f3c35cd4a249cd8d7c579328bd575a3 to your computer and use it in GitHub Desktop.
Save suhailgupta03/3f3c35cd4a249cd8d7c579328bd575a3 to your computer and use it in GitHub Desktop.
function sum(a, b) {
let sum = a + b;
return sum;
// role of return is to "return" the
// value of sum to the caller
}
function isUserLoggedIn() {
let user = {
name: "John",
loggedIn: true
}
return user.loggedIn;
}
// let x = 300
// or to write this using function you can
// write as follows
let x = sum(100, 200);
console.log(x);
let y = sum(10, 100);
console.log(y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment