You need to close the actions of the IF statement in {}, if they contain more than one instructions.

This is perfectly fine :
Code: java
if (x=="Dave")
      document.write("Yourname is Dave");
But, this :
Code: java
if (x=="Dave")
      document.write("Yourname is Dave");
      document.write("Welcome Dave !");
will not function as expected from the indentation of the code. It will function similar to :
Code: java
if (x=="Dave")
      document.write("Yourname is Dave");
document.write("Welcome Dave !");
So, ifor the correct functioning, you must close both statements within {}.
Code: java
if (x=="Dave")
{
      document.write("Yourname is Dave");
      document.write("Welcome Dave !");
}

I hope, you got it.