Q3 Computer 10 Week 1
Q3 Computer 10 Week 1
Q3 Computer 10 Week 1
PROGRAMMING
Performing Mensuration and Calculation
OBJECTIVES:
function greet()
3. Every line of codes ends in a semi colon (
document.write(“I’m a programmer”);
Structure and Syntax
4. Comments- are remarks added to describe
certain parts of codes in a program
// single-line comment
/* this is a multi
line comment */
General structure and syntax of a JavaScript code inside HTML
<html>
<head>
<title> javascript sample code </title>
</head>
<body>
<script type = “text/javascript”>
</script>
</body>
</html>
General structure and syntax of a JavaScript code inside HTML
<html>
<head>
<title> javascript sample code </title>
Statement is placed between
</head> <script> and </script>
<body>
<script type = “text/javascript”>
document.write() displays
document.write (“HELLO WORLD!”); whatever string is entered
inside the parenthesis
</script> between the open and close
</body> quotation marks “ “.
</html>
Integrating HTML tags to format text content in JavaScript
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Hello");
document.write("World");
You will see that there is
</script>
no space between the
</body> HelloWorld output.
</html>
Integrating HTML tags to format text content in JavaScript
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Hello“ + “<br>”); • You will observe that a + symbol is
document.write("World"); added
</script> • The html tag <br> is used and is placed
between the “ “.
</body> • The + symbol combines the <br> tag
</html> with the text Hello which is telling the
browser to display the output of the
JavaScript Variables
Variables Variable is a temporary
storage that represents a
value.
JavaScript Variables
Variables Variable is a temporary storage that
represents a value.
Example:
var x = 5
<script type>
var x = 5
document.write (x)
</script>
OUTPUT:
5
JavaScript Variables
What is the result of the following
code?
<script type>
var x = 5
document.write (x);
document.write (“x”);
</script> OUTPUT:
5x
Answer
Exercises and Assessment in
Module 1
• Upload answer in pdf format