Is that all the code that's provided?
If so, it will be a lot easier if you look at the code formatted sanely:
Code: Select all
if(Day == "Friday")
{
document.write("T.G.I.F!");
}
else
{
if(Day == "Monday")
{
document.write("Another Manic Monday!");
}
else
{
document.write("Good morning");
}
}
You need to understand if statements.
if(expression)
{
// the code inside this block is executed
// if expression evaluates to true.
}
else
{
// the code inside this block is executed
// if expression evaluates to false.
}
So that code snippet works as follows.
Is the variable Day equivalent to the string expression "Friday"?
- If so, then call the write method on the document object with the argument "T.G.I.F."
- If not, then do the following:
-- Is the variable Day equivalent to the string expression "Monday"?
--- If so, then call the write method on the document object with the argument "Another Manic Monday!"
--- If not, then call the write method on the document object with the argument "Good morning"