My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

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;
}