Skip to content

Commit 9db6fb7

Browse files
committed
updates
1 parent d254107 commit 9db6fb7

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed

API-HTTP_GET_method/index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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>HTTP GET METHOD</title>
7+
<style>
8+
body{
9+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
10+
color: #0F141E;
11+
padding: 30px 100px;
12+
background: aliceblue;
13+
}
14+
ul{
15+
display: inline-block;
16+
}
17+
h1{
18+
color: #080e50;
19+
}
20+
p{
21+
color: red;
22+
}
23+
</style>
24+
</head>
25+
<body>
26+
<h1>JSON</h1>
27+
<h1>JavaScript Object Notation</h1>
28+
<h2>Dynamically Display data from server:</h2>
29+
30+
<ul id="display_data">
31+
<h4>Name:</h4>
32+
</ul>
33+
34+
<ul id="display_email">
35+
<h4>Email:</h4>
36+
37+
</ul>
38+
39+
<script src="script.js"></script>
40+
</body>
41+
</html>

API-HTTP_GET_method/script.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// const user = {
2+
// id: 3,
3+
// name: "saidul Islam"
4+
// };
5+
6+
// const jsonConvert = JSON.stringify(user);
7+
// console.log(jsonConvert); // {"id":3,"name":"saidul Islam"}
8+
9+
fetch('https://jsonplaceholder.typicode.com/users')
10+
.then(response => response.json())
11+
.then(json => displayUsers(json))
12+
.catch(error => console.log(error))
13+
14+
function displayUsers(users){
15+
console.log(users);
16+
17+
const name = users.map(username => username.name);
18+
const email = users.map(username => username.email);
19+
let ul = document.getElementById("display_data");
20+
let ulEmail = document.getElementById("display_email");
21+
22+
// const id = users.map(username => username.id);
23+
// const email = users.map(username => username.email);
24+
// console.log(name , id , email);
25+
displayData(name, ul);
26+
displayData(email, ulEmail);
27+
28+
function displayData(userName, listParent){
29+
for (let i = 0; i < userName.length; i++) {
30+
const element = userName[i];
31+
const li = document.createElement("li");
32+
li.innerText = element;
33+
listParent.appendChild(li);
34+
35+
}
36+
}
37+
38+
}
39+
40+
41+
//Status Code All:
42+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
43+
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

objcall.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const normalPerson = {
2+
firstName : "Saidul",
3+
lastName : "Islam",
4+
salary : 15000,
5+
getFullName : function(){
6+
console.log(this.firstName + " " + this.lastName);
7+
},
8+
chargeBill : function(amount , tips , tax){
9+
this.salary = this.salary - amount - tips - tax
10+
return this.salary
11+
}
12+
}
13+
14+
// normalPerson.chargeBill(3000);
15+
// normalPerson.chargeBill(3000);
16+
// console.log(normalPerson.salary);
17+
18+
const friendlyPerson = {
19+
firstName : "Shymoli",
20+
lastName : "Begum",
21+
salary : 52000
22+
}
23+
24+
25+
//Apply Call Method
26+
27+
normalPerson.chargeBill.call(friendlyPerson , 5000 , 200 , 50);
28+
29+
console.log(friendlyPerson.salary);
30+
31+
32+
normalPerson.chargeBill.apply(friendlyPerson , [5000 , 200 , 50]);
33+
34+
console.log(friendlyPerson.salary);
35+
36+
37+

objmethod-bind.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const normalPerson = {
2+
firstName : "Saidul",
3+
lastName : "Islam",
4+
salary : 15000,
5+
getFullName : function(){
6+
console.log(this.firstName + " " + this.lastName);
7+
},
8+
chargeBill : function(amount){
9+
this.salary = this.salary - amount
10+
return this.salary
11+
}
12+
}
13+
14+
// normalPerson.chargeBill(3000);
15+
// normalPerson.chargeBill(3000);
16+
// console.log(normalPerson.salary);
17+
18+
19+
const heroPerson = {
20+
firstName : "Moni",
21+
lastName : "Islam",
22+
salary : 35000
23+
}
24+
const friendlyPerson = {
25+
firstName : "Shymoli",
26+
lastName : "Begum",
27+
salary : 52000
28+
}
29+
//apply bind method
30+
const heroChargeBill = normalPerson.chargeBill.bind(heroPerson)
31+
32+
heroChargeBill(5000)
33+
heroChargeBill(4000)
34+
console.log(heroPerson.salary);
35+
36+
37+
//apply bind method
38+
const friendlyChargeBill = normalPerson.chargeBill.bind(friendlyPerson)
39+
40+
friendlyChargeBill(2000)
41+
console.log(friendlyPerson.salary);
42+
43+

0 commit comments

Comments
 (0)