Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 12:13
Show Gist options
  • Save iamsaief/1c689b029c0b940b2f3ee78a504325ba to your computer and use it in GitHub Desktop.
Save iamsaief/1c689b029c0b940b2f3ee78a504325ba to your computer and use it in GitHub Desktop.
/* Arrow functions - implicit return*/
const doubleIt = (num) => num * 2;
console.log(doubleIt(4));
// Output: 8
const add = (a, b) => a + b;
console.log(add(40, 50));
// Output: 90
/* explicit return */
const sumTimesDifference = (x, y) => {
const sum = x + y;
const diff = x - y;
return sum * diff;
};
console.log(sumTimesDifference(20, 10));
// Output: 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment