Skip to content

Commit d0e8af8

Browse files
Completed Day 5 on 10/12/2020
1 parent 5cf4fd1 commit d0e8af8

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

Diff for: Day 5/Problem 1/Create_A_rectangle_object.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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>Create a Rectangle Object</title>
7+
</head>
8+
<body>
9+
<h1>Day 5</h1>
10+
<h4>Probem 1</h4>
11+
</body>
12+
<script src="script.js"></script>
13+
</html>

Diff for: Day 5/Problem 1/script.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function Rectangle(a, b) {
2+
3+
var rec = {
4+
length:a,
5+
width:b,
6+
perimeter:2 * (a + b),
7+
area:a * b,
8+
}
9+
return rec;
10+
}
11+
12+
const rec = new Rectangle(6, 4);
13+
14+
console.log(rec.length);
15+
console.log(rec.width);
16+
console.log(rec.perimeter);
17+
console.log(rec.area);

Diff for: Day 5/Problem 2/Count_objects.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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>Count Objects</title>
7+
</head>
8+
<body>
9+
<h1>Day 5</h1>
10+
<h4>Problem 2</h4>
11+
</body>
12+
<script src="script.js"></script>
13+
</html>

Diff for: Day 5/Problem 2/script.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function getCount(objects) {
2+
3+
var count = 0;
4+
for (var i in objects){
5+
if(objects[i].x == objects[i].y){
6+
count++;
7+
}
8+
}
9+
return count;
10+
11+
}
12+
13+
for (let i = 0; i < 3; i++) {
14+
const [a, b] = [1,1, 2,4, 4,4].split(",");
15+
16+
objects.push({x: +(a), y: +(b)});
17+
}
18+
19+
console.log(getCount(objects));

Diff for: Day 5/Problem 3/Classes.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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>Classes</title>
7+
</head>
8+
<body>
9+
<h1>Day 5</h1>
10+
<h4>Problem 3</h4>
11+
</body>
12+
<script src="script.js"></script>
13+
</html>

Diff for: Day 5/Problem 3/script.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Polygon{
2+
3+
constructor(sides){
4+
this.values = sides;
5+
}
6+
7+
perimeter(){
8+
9+
var total = 0;
10+
11+
for(var i of this.values){
12+
total = total + i;
13+
}
14+
return total;
15+
}
16+
}
17+
18+
const rectangle = new Polygon([10, 20, 10, 20]);
19+
const square = new Polygon([10, 10, 10, 10]);
20+
const pentagon = new Polygon([10, 20, 30, 40, 43]);
21+
22+
console.log(rectangle.perimeter());
23+
console.log(square.perimeter());
24+
console.log(pentagon.perimeter());

0 commit comments

Comments
 (0)