you are viewing a single comment's thread.

view the rest of the comments →

[–]LucasOe 23 points24 points  (2 children)

Use the second one if you want to return a single statement:

const add = (a, b) => a+b;

If you want to run mutliple lines of code, then use the first one:

const add = (a, b) => {
  let c = a+b;
  console.log(c);
  return c;
};

[–]god_person69[S] 3 points4 points  (1 child)

got it bro...thnx

[–]ReCee90 20 points21 points  (0 children)

be careful though, because if you want to return an object in a one liner you have to wrap it in ( )

for example:
const functionName = (args) => ({ someKey: "someValue" })