In this javascript code if else statement working very well but i don't know why remaining code is not working?

The code example does look off, so I can understand how it might resemble PHP’s Alternative syntax for control structures

I always do

if(a == i){
 b=i;
}else{
 b=null;
}

with the curly braces