Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 0ec00d8

Browse files
committed
Abdullah Al Ahmad
JavaScript homework - week1
1 parent 549f912 commit 0ec00d8

File tree

2 files changed

+187
-0
lines changed

2 files changed

+187
-0
lines changed

Week1/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<script src="js1-w2.js"></script>
11+
</body>
12+
</html>

Week1/js1-w1-A.A.A.js

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
// Greetings
2+
3+
console.log ('Hello World!'); //English
4+
5+
console.log ('Halo, Dunia!'); // Indonesian
6+
7+
console.log ('Ciao Mondo!'); // Italian
8+
9+
console.log ('Hola Mundo!'); // Spanish
10+
11+
12+
// Debug single quote issue
13+
14+
console.log('I\'m awesome');
15+
16+
// Variables & Values
17+
18+
var x;
19+
20+
console.log("the value of my variable x will be: a number");
21+
22+
console.log(x);
23+
24+
x = 12;
25+
26+
console.log("the value of my variable x will be: a number");
27+
28+
console.log(x);
29+
30+
var y = 'Tom';
31+
32+
console.log("the value of my atring y will be: a name");
33+
34+
console.log(y);
35+
36+
var y = y + '&Jerry';
37+
38+
console.log("the value of my string y will be: a cartoon name");
39+
40+
console.log(y);
41+
42+
var z = 7.25;
43+
44+
console.log(z);
45+
46+
// Round z to the closest integer
47+
48+
var round = Math.round;
49+
50+
var a = round(z);
51+
52+
console.log(a);
53+
54+
// Print higher value z or a
55+
56+
if (a<z) {
57+
var i = z;
58+
console.log(i);
59+
60+
} else {
61+
var i = a;
62+
console.log(i);
63+
64+
}
65+
66+
// Animals Names
67+
68+
var myFavoriteAnimals;
69+
70+
console.log('The value of heros is: animales\'s names');
71+
72+
console.log(myFavoriteAnimals);
73+
74+
myFavoriteAnimals = ['monkey', 'horse', 'turtle'];
75+
76+
console.log(myFavoriteAnimals);
77+
78+
myFavoriteAnimals = myFavoriteAnimals + [', baby pig'];
79+
80+
console.log(myFavoriteAnimals);
81+
82+
// String Length
83+
84+
let myString = "this is a test";
85+
86+
console.log(myString);
87+
88+
console.log(myString.length);
89+
90+
// Types of Data
91+
92+
var success = 'Congats! the data type of your variables is identical!';
93+
94+
console.log(success + ' * this is a string');
95+
96+
console.log(typeof success);
97+
98+
99+
var failure = 'Oops! the data type of your variables is different!';
100+
101+
console.log(failure + ' * this is a string');
102+
103+
console.log(typeof failure);
104+
105+
106+
var number = 1;
107+
108+
console.log(number + ' * this is a number');
109+
110+
console.log(typeof number);
111+
112+
113+
var boolean = true;
114+
115+
console.log(boolean + ' * this is a boolean');
116+
117+
console.log(typeof boolean);
118+
119+
120+
var array = [0, 1, 2, 3, 4];
121+
122+
console.log(array + ' * this is an object');
123+
124+
console.log(typeof array);
125+
126+
// Testing type of data
127+
128+
if (typeof success === typeof failure) {
129+
130+
console.log(success);
131+
132+
} else {
133+
console.log(failure);
134+
}
135+
136+
137+
if (typeof success === typeof number) {
138+
console.log(success);
139+
140+
} else {
141+
console.log(failure);
142+
}
143+
144+
145+
if (typeof boolean === typeof array) {
146+
console.log(success);
147+
148+
} else {
149+
console.log(failure);
150+
}
151+
152+
// Explaining %
153+
154+
console.log(x);
155+
156+
console.log ('x % 5 will be 2 which is the leftover number that cannot be divided on 5');
157+
158+
console.log(x % 5);
159+
160+
// Array with multiple data types
161+
162+
console.log('following array contains 2 numbers, 2 strings and a boolean');
163+
164+
var multipleTypesArray = [0, 'hero', 2, 'too', false];
165+
166+
console.log(multipleTypesArray);
167+
168+
// Comparing infinities
169+
170+
if (10/0 === 6/0) {
171+
console.log('Yes! they\'re equal!');
172+
173+
} else {
174+
console.log('There\'s no equality in this!');
175+
}

0 commit comments

Comments
 (0)