Skip to content

Commit 6407a88

Browse files
committed
Use Existing Arrays as Elements
1 parent dd8fea3 commit 6407a88

File tree

3 files changed

+122
-1
lines changed

3 files changed

+122
-1
lines changed

first/array.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
let numbers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
2+
3+
console.log(numbers[1]);
4+
5+
console.log(numbers[3]);
6+
7+
// Using the push() Method //
8+
9+
let dailyActivities = ["eat", "sleep"];
10+
11+
dailyActivities.push("exercise");
12+
13+
console.log(dailyActivities);
14+
15+
16+
17+
let dailyActivitie = ["eat", "sleep"];
18+
19+
dailyActivitie.unshift("exercise");
20+
21+
console.log(dailyActivitie);
22+
23+
24+
// Use Existing Arrays as Elements //
25+
26+
let student1 = ['Jack', 24];
27+
let student2 = ['Sara', 23];
28+
let student3 = ['Peter', 24];
29+
30+
let studentsData = [student1, student2, student3];
31+
32+
console.log(studentsData);

first/function.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,27 @@ let squared = function(num) {
2929
return num * num;
3030
}
3131

32-
console.log(squared(50));
32+
console.log(squared(50));
33+
34+
function counter(count) {
35+
36+
37+
console.log(count);
38+
39+
40+
if(count > 1) {
41+
42+
43+
count = count - 1;
44+
45+
46+
counter(count);
47+
} else {
48+
49+
50+
return;
51+
};
52+
};
53+
54+
55+
counter(5);

first/objects.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const student = {
2+
firstname: "Jeny",
3+
rollno: 18
4+
};
5+
6+
console.log(student);
7+
8+
const cat = {
9+
name: "Kavaya",
10+
}
11+
console.log(cat.name);
12+
13+
const gog = {
14+
name: "Jeny",
15+
}
16+
17+
console.log(gog["name"]);
18+
19+
const person = {
20+
name: "John",
21+
hobby: "Singing",
22+
}
23+
24+
person.hobby = "Dancing";
25+
26+
console.log(person);
27+
28+
const employee = {
29+
name: "Tom",
30+
position: "officer",
31+
salary: 30000,
32+
}
33+
34+
delete employee.salary
35+
36+
console.log(employee);
37+
38+
const dogs = {
39+
name: "Meth",
40+
41+
bark: function () {
42+
console.log("Woofl");
43+
}
44+
};
45+
46+
dogs.bark();
47+
48+
//Prototype Inheritance//
49+
50+
function Car(model, year) {
51+
this.model = model;
52+
this.year = year;
53+
};
54+
55+
let c1 = new Car("Mustang", 1984);
56+
let c2 = new Car("Corolla", 1986);
57+
58+
Car.prototype.drive = function() {
59+
console.log(`Driving ${this.model}`);
60+
};
61+
62+
console.log(`${c1.model} color: ${c1.color}`);
63+
console.log(`${c2.model} color: ${c2.color}`);
64+
65+
c1.drive();
66+
c2.drive();

0 commit comments

Comments
 (0)