Script NG El Filibusterismo
Script NG El Filibusterismo
Script NG El Filibusterismo
(using document.write)
Create an HTML named: [YourName].
Welcome to JavaScript [Your Name]!!!
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
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
Fixed values
variable values.
FIXED VALUES
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
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;
ex.
var person = "John Doe", carName = "Volvo", price = 200;
ACTIVITY
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
</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>
<script>
// Create the variable here
</script>
</body>
</html>
Answer: <!DOCTYPE html>
<html>
<body>
<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>
<script>
// Create the variable here
</script>
</body>
</html>
2. The code below should display "Volvo" - Fix it.
<!DOCTYPE html>
<html>
<body>
<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>
<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>
<script>
var x = 5;
var y = 10;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
var x = 5;
var y = 10;
document.getElementById("demo").innerHTML = x + y;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
</html>