DEV Community

Discussion on: Refactoring Code in Octo!

Collapse
 
lgrammel profile image
Lars Grammel

Great post!

I think your lineChecker function would be a great, small refactoring kata. Here's how it looked after I refactored it:

const lineChecker = (line, isFirstLine) => {
  if (line === "") {
    return "<br />";
  }

  return isFirstLine ? `<h1>${line}</h1>` : `<p>${line}</p>`;
};
Enter fullscreen mode Exit fullscreen mode

Would you mind if I use it as an example and trial ground for a refactoring tool I'm developing? ( marketplace.visualstudio.com/items... )

Collapse
 
luigizaccagnini profile image
Luigi Zaccagnini

Thank you for asking, I do not mind at all! I also think your tool is very cool! Thank you for sharing it with me!

Collapse
 
lgrammel profile image
Lars Grammel

Thanks 😊

Collapse
 
lgrammel profile image
Lars Grammel

I was curious how other people would refactor it, so I posted it here: dev.to/p42/how-would-you-refactor-...