You are on page 1of 2

<HTML>

<HEAD>
<TITLE>My First JavaScript</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
document.write("I love JavaScript");
//-->
</SCRIPT>
</BODY>
</HTML>

-----------------------

ASSIGNMENT:

What do you think happens when you use DOCUMENT.WRITE instead of document.write?
What will be displayed if you don't enclose the text inside write() with quotes?
Write code that prints your name.
Write code that displays It's a good day to die.
What is the correct JavaScript code for displaying the following?
He said, "Welcome to my world."

JavaScript Basics Tutorial - Assignment answers

1.JavaScript is case-sensitive. Thus, using DOCUMENT.WRITE instead of


document.write will result in an error.

2. Forgetting to include the quotes results in an error. The text needs to be


surrounded by quotes and placed inside parenthesis.

3. <script language="JavaScript" type="text/javascript">


<!--
document.write("Your-name-here");
//-->
</script>

4.<script language="JavaScript" type="text/javascript">


<!--
document.write("It's a good day to die");
//-->
</script>

5.<script language="JavaScript" type="text/javascript">


<!--
document.write('He said, "Welcome to my world."');
//-->
</script>
Note: The double quotes are surrounded by single quotes.
-----------------------------------------

You might also like