Skip to content

Commit 20551ca

Browse files
committed
Separate into folders
1 parent 6011e61 commit 20551ca

4 files changed

Lines changed: 58 additions & 33 deletions

File tree

chapter 3/app.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Question# 1
2+
// Declare a variable called age & assign to it your age. Show
3+
// your age in an alert box.
4+
5+
var age = 5;
6+
alert("I am" + " " + age + " " + "years old.");
7+
console.log("I am" + " " + age + " " + "years old.");
8+
9+
// Question# 2
10+
// Declare & initialize a variable to keep track of how many
11+
// times a visitor has visited a web page. Show his/her
12+
// number of visits on your web page. For example: “You
13+
// have visited this site N times”.
14+
15+
var visit_count;
16+
visit_count = 10;
17+
alert("You have visited this site" + " " + visit_count + " " + "times.");
18+
console.log("You have visited this site" + " " + visit_count + " " + "times.");
19+
20+
// Question# 3
21+
// Declare a variable called birthYear & assign to it your
22+
// birth year. Show the following message in your browser:
23+
24+
var birth_year = 2015;
25+
document.write("My birth year is" + " " + birth_year + "<br/>");
26+
document.write(
27+
"Data type of my declared variable is number" + "<br/>"
28+
);
29+
30+
// Question# 4
31+
// A visitor visits an online clothing store
32+
// www.xyzClothing.com . Write a script to store in variables
33+
// the following information:
34+
// b. Product title
35+
// c. Quantity i.e. how many products a visitor wants to
36+
// order
37+
// Show the following message in your browser: “John
38+
// Doe ordered 5 T-shirt(s) on XYZ Clothing store”.
39+
40+
var product_name = "T-Shirts";
41+
var quantity = 5;
42+
var visitor_name = "John Doe";
43+
44+
document.write(`${visitor_name} ordered ${quantity} ${product_name} on XYZ Clothing store`);

chapter 3/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Chapter 3 Task | VARIABLES FOR NUMBERS </title>
7+
</head>
8+
<body>
9+
<script src="app.js"></script>
10+
</body>
11+
</html>

index.html renamed to chapter 4/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>VARIABLES FOR NUMBERS</title>
6+
<title>Chapter 4 Task | VARIABLE NAMES: LEGAL & ILLEGAL </title>
77
</head>
88
<body>
99
<script src="script.js"></script>

script.js renamed to chapter 4/script.js

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,9 @@
11
// Question# 1
2-
// Declare a variable called age & assign to it your age. Show
3-
// your age in an alert box.
4-
5-
var age = 5;
6-
alert("I am" + " " + age + " " + "years old.");
7-
console.log("I am" + " " + age + " " + "years old.");
8-
9-
// Question# 2
10-
// Declare & initialize a variable to keep track of how many
11-
// times a visitor has visited a web page. Show his/her
12-
// number of visits on your web page. For example: “You
13-
// have visited this site N times”.
14-
15-
var visit_count;
16-
visit_count = 10;
17-
alert("You have visited this site" + " " + visit_count + " " + "times.");
18-
console.log("You have visited this site" + " " + visit_count + " " + "times.");
19-
20-
// Question# 3
21-
// Declare a variable called birthYear & assign to it your
22-
// birth year. Show the following message in your browser:
23-
24-
var birth_year = 2015;
25-
document.write("My birth year is" + " " + birth_year + "<br/>");
26-
document.write(
27-
"Data type of my declared variable is number" + "<br/>" + "<br/>"
28-
);
29-
30-
// Question# 4
312
// Declare 3 variables in one statement.
323
var age;
334
var year;
345
var date;
35-
36-
// Question# 5
6+
// Question# 2
377
// Declare 5 legal & 5 illegal variable names.
388
// ==============================================
399
// 5 Legal Variable name
@@ -50,7 +20,7 @@ var $person_name;
5020
// var class; //reserved key is not being used because it has already been reserved and cannot used as variable it throws error.
5121
// var car*name; //special characters cannot be used between variable but $ sign can be used.
5222

53-
// Question# 6
23+
// Question# 3
5424
// Display this in your browser
5525
// a) A heading stating “Rules for naming JS variables”
5626
var rules_for_JS = "Rules for naming JS variables" + "<br/>" + "<br/>";

0 commit comments

Comments
 (0)