Can I get some input on formatting?

// THE WAY I SEE IT ON SO MANY JAVASCRIPT LESSONS IN AND OUT OF CODECADEMY
const plantNeedsWater = (day) => {
  if (day === 'Wednesday') {
    return true;
  } else {
    return false;
  }
};


// **THE WAY I PREFER TO WRITE, COMING FROM C++.**

const plantNeedsWater = (day) =>
  {
    if(day === "Wednesday")
      {
        return true;
      }
    else
      {
        return false;
      }
  };

To be honest, the way I format seems so much easier to read, but again I see the top formatting so often when using Codecademy, even the instructor’s videos. Is the formatting way I use okay, or will I be discouraged from formatting this way at some point?

Thanks!

Correct me if I’m wrong, but Javascript is pretty lenient when it comes to formatting- so I think you just need to keep in mind the readability of your formatting.
For me, I prefer your way better (this coming from someone who specializes in Python).

It depends. When you start working on group projects or in a business environment, there may be coding style standards in place. Sometimes adhering to those standards will be assisted by and/or enforced with 3rd party tools that can be set to automatically reformat the code upon saving. such as Prettier, Beautify, ESLint, etc. etc.

There are a lot of different style guides out there and even more opinions on style. Here’s an article that talks about some of them: 5 JavaScript Style Guides — Including AirBnB, GitHub, & Google

For personal projects, you can use whatever you want.

1 Like

Cool. Thanks!! :grinning:

Yes, I don’t get errors or anything, just want to make sure I’m not heading down a doomed path :joy:

1 Like