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