Norway123
New Coder
Hi. I started recently to read and solve excercises in the book "A smarter way to learn javascript". I have been working with javascript for around 2 months, but does not master the fundamentals yet, so I decided to give this book a shoot.
my question: I have been working with comparison operator in this book now and i find it a bit frustrating that the author of the book using parentheses after to seperate statements. You dont need to do that, does he use it only because it makes the code cleaner to read? I have been using codeacedemy and freecodecamp, and none of them using this.
for example:
if (a < b || (c > d || c === e))
if ((name === "Rob" || name === "Moskus") && age > 60)
if ((name === "Rob" && age > 60) || (name === "Moskus" || age < 6))
it works exactly the same way when writing in this way: if (a < b || c > d || c === e), if (name === "Rob" || name === "Moskus" && age > 60), if (name === "Rob" && age > 50 || name === "Moskus" || age < 6);
my question: I have been working with comparison operator in this book now and i find it a bit frustrating that the author of the book using parentheses after to seperate statements. You dont need to do that, does he use it only because it makes the code cleaner to read? I have been using codeacedemy and freecodecamp, and none of them using this.
for example:
if (a < b || (c > d || c === e))
if ((name === "Rob" || name === "Moskus") && age > 60)
if ((name === "Rob" && age > 60) || (name === "Moskus" || age < 6))
it works exactly the same way when writing in this way: if (a < b || c > d || c === e), if (name === "Rob" || name === "Moskus" && age > 60), if (name === "Rob" && age > 50 || name === "Moskus" || age < 6);