Vous êtes sur la page 1sur 50

QUIZ

1. It is where codes and


formulas are processed right on
the user’s computer
2. It is a standardized
communication technique for
expressing instructions to a
computer.
3. True or False: Low level
languages were developed first,
and high level languages came
along later
4. True or False: Javasript is a case-
sensitive language.
5. What is the meaning of DHTML?
6. Javascript was developed by?
7. It was first introduced and deployed
in the NETSCAPE browser version 2.0B
in ________(month and year)
8. Javascript was designed to add
interactivity and ____________
to the website.
9-10. Give the two(2) CATEGORIES OF
PROGRAMMING LANGUAGES
10 pts.

(using document.write)
Create an HTML named: [YourName].
Welcome to JavaScript [Your Name]!!!

Ex. Welcome to JavaScript Rajiv Buisan!!!


JAVASCRIPT STATEMENTS
AND SYNTAX
01
VALUES
05 02
JAVA
SCRIPT

KEYWORDS

04 03
designed by

tinyppt.com
document.getElementById(“ULS").innerHTML =
"Hello ULS.";
<!DOCTYPE html>
<html> <script>
<body> document.getElementById(“ULS").innerHTML =
"Hello Dolly.";
</script>
<h2>JavaScript
Statements</h2> </body>
</html>
<p>In HTML, JavaScript
statements are executed by
the browser.</p>

<p id=“EINSTEIN"></p>
Most JavaScript programs contain many
JavaScript statements.
The statements are executed, one by one, in
the same order as they are written.
Semicolons separate JavaScript statements

Add a semicolon at the end of


each executable statement:

designed by

tinyppt.com
var a, b, c; // Declare 3 variables
a = 5; // Assign the value 5 to a
b = 6; // Assign the value 6 to b
c = a + b; // Assign the sum of a
and b to c
JAVASCRIPT SYNTAX

JavaScript syntax is the set of rules, how


JavaScript programs are constructed:
JavaScript Values

Fixed values

variable values.
FIXED VALUES

• Numbers are written • Strings are text,


with or without written within double
decimals: or single quotes:
• 10.50 • "John Doe"

1001 'John Doe'

NUMBERS STRINGS
JavaScript Variables

JavaScript Variables
In a programming language, variables are used
to store data values.
JavaScript uses the var keyword to declare variables.
An equal sign is used to assign values to variables

Ex. var x;

x = 6;
JavaScript Identifiers

All JavaScript variables must be identified with unique names.

These unique names are called identifiers.

Identifiers can be :
x, y
Or
age, sum, totalVolume
GENERAL RULES
Names can contain
letters, digits,
underscores, and
dollar signs.
Names must begin
with a letter,
underscores, $ sign

CASE
SENSITIVE
Reserved words (like
JavaScript keywords)
cannot be used as
names
designed by

tinyppt.com
In JavaScript, the equal sign (=) is an
"assignment" operator, not an "equal to"
operator.
Assignment operator

var x = 6;
value

variable identifier
var price1 = 5;
var price2 = 6;
var total = price1 + price2;

In programming, just like in algebra, we use


variables (like price1) to hold values.
In programming, just like in algebra, we use
variables in expressions (total = price1 + price2).
From the example above, you can calculate the
total to be 11.
 You can declare many variables in one statement.

Start the statement with var and separate the variables


by comma:

ex.
var person = "John Doe", carName = "Volvo", price = 200;
ACTIVITY
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Variables</h2> <script>


var x;
x = 6;
<p>In this example, x is defined as a document.getElementById("demo").innerHTML = x;
variable. </script>
Then, x is assigned the value of 6:</p>
</body>
<p id="demo"></p> </html>
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Variables</h2>

<p>You can declare many variables in one


statement.</p>
<p id="demo"></p>
<script>
var person = "John Doe", carName = "Volvo",
price = 200;
document.getElementById("demo").innerHTML
= price;
</script>

</body>
</html>
1. In a programming
language, _______ are used
to store data values.
2. TRUE OR FALSE
You cannot declare many variables in
one statement.
3. Start the statement with var and
separate the variables by ______
4–5
2 types of JAVASCRIPT VALUES
6.
______are text, written within double
or single quotes
7.
JavaScript uses the _____keyword
to declare variables.
8. TRUE OR FALSE
Reserved words (like JavaScript keywords)
cannot be used as names
9.

var x = 6;
value

variable 10.
Create a variable called carName, assign the value
"Volvo" to it, and display it.
<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
// Create the variable here
</script>

</body>
</html>
Answer: <!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
var carName = "Volvo";
document.getElementById("demo").innerHTML = carName;
</script>

</body>
</html>
1. Create a variable called number, assign the
value 50 to it, and display it.
<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
// Create the variable here
</script>

</body>
</html>
2. The code below should display "Volvo" - Fix it.
<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
var carName = "Volvo";
document.getElementById("demo").innerHTML = carname;
</script>

</body>
</html>
3. Display the sum of 5 + 10, using two variables x and y.
<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
// Create the variables here
</script>

</body>
</html>
Create a third variable called z, assign x + y to it, and
display it. <!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
var x = 5;
var y = 10;
</script>

</body>
</html>
<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>

<script>
var x = 5;
var y = 10;
document.getElementById("demo").innerHTML = x + y;
</script>

</body>
</html>
<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p>


<script>
var x = 5;
var y = 10;
var z = x + y;
document.getElementById("demo").innerHTML = z;
</script>

</body>
</html>

Vous aimerez peut-être aussi