0% found this document useful (0 votes)
89 views16 pages

Q3 Computer 10 Week 1

This document introduces JavaScript programming and covers its structure and syntax, as well as variables. It explains that JavaScript is a scripting language used to implement complex features on web pages, and discusses JavaScript's case sensitivity, required spacing, and use of semicolons. The document also demonstrates how to write basic JavaScript code within HTML tags and how to use variables to store and output values.

Uploaded by

Andrhey Bagonbon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views16 pages

Q3 Computer 10 Week 1

This document introduces JavaScript programming and covers its structure and syntax, as well as variables. It explains that JavaScript is a scripting language used to implement complex features on web pages, and discusses JavaScript's case sensitivity, required spacing, and use of semicolons. The document also demonstrates how to write basic JavaScript code within HTML tags and how to use variables to store and output values.

Uploaded by

Andrhey Bagonbon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

INTRODUCTION TO JAVASCRIPT

PROGRAMMING
Performing Mensuration and Calculation
OBJECTIVES:

• Analyze and explain the structure


and syntax of JavaScript
• Explain what a variable is and how
it works in a program
• JavaScript is a scripting What is
or programming JavaScript?
language that allows you
to implement complex
features on web pages.
• Created by Brendan Eich
Structure and Syntax

1. JavaScript is case sensitive


var a = 2
var A = 4

Variable a is different from variable A


Structure and Syntax
2. JavaScript requires one space between
keywords, identifiers and names.

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”>

document.write (“HELLO WORLD!’);

</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

var is the keyword for variable


x is the variable name or identifier
= is the assignment operator
JavaScript Variables
Variables Rules in naming JavaScript
Variables
1. A variable name should begin with a letter
such as x, num1.
2. A variable name cannot start with any
number such as 3y, 2 num
3. A variable name should not be a
JavaScript reserved word such as delete.
4. A variable name is case sensitive
JavaScript Variables
What is the result of the following code?

<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

You might also like