Hacker News new | past | comments | ask | show | jobs | submit login

That will work, because console.log() returns undefined.

It is a bit subtle for my taste, though. My suggestion for clarity is to go ahead and make the function have a body with {}:

  const upperCase = (message) => {
    console.log(message);
    return message.upperCase();
  };
Of course you may disagree, but no argument there, as I said it's a matter of taste.

(BTW backticks, either triple or single, do not work on HN. Indent by two spaces if you want code formatting.)




Yeah, I'm working on the assumption that this code is not committed but for a quick debug.

Any code that is shared shouldn't rely on that, I agree.

Thanks for the tip!


Since most of the times I want "a quick debug" I'm already on my browser and quite probably with the dev tools already open, I prefer right-clicking on a line and using "Add Log" (in Firefox) or "Add logpoint" (in Chrome-based browsers). It avoids having to modify the source and then clean it up when I'm done.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: