Sign in
Log inSign up

Is it o'key to write else statement before if?

Ankur Singh's photo
Ankur Singh
·Aug 23, 2019

Which is good?

var1 = 10;
if (condition == true) {
  var1 = 20;
}

or

if (condition == true) {
  var1 = 20;
} else {
  var1 = 10;
}
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct