-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
142 lines (120 loc) · 2.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
console.log(add(1, 2));
function add(a, b) {
// function body
return a + b;
}
var subtract = function (a, b) {
// function body
return a - b;
};
// console.log(subtract(5,3));
function createUser(name, initiaBalance) {
let balance = initiaBalance;
return {
userName:name,
getBalance: function () {
return balance;
},
getName: function () {
return this.userName;
},
deposit: function (amount) {
balance += amount;
},
withdraw: function (amount) {
if (amount <= balance) {
balance -= amount;
} else {
throw Error(
`your balance: ${balance} is not enough to withdraw ${amount}`
);
}
},
};
}
const ali = createUser("Ali", 0);
console.log(ali)
console.log(ali.getBalance());
ali.userName = "taha";
console.log(ali)
console.log(ali.getName());
ali.deposit(1000);
console.log(ali.getBalance());
// don't try to be clever?
// the crown of complexity is simplicity?
// examples:
// fetch()
// The Fetch API provides an interface for fetching resources.
// It is a more powerful and flexible replacement for XMLHttpRequest.
// For making a request and fetching a resource, use the fetch() method.
// It is a global method in Window
// The fetch() method takes one mandatory argument, the path to the resource you want to fetch.
// It returns a Promise that resolves to the Response to that request — as soon as the server responds with headers —
// even if the server response is an HTTP error status.
// fetch("https://dummyjson.com/products/1")
// .then((res) => res.json())
// .then((json) => console.log(json));
// promise
// .then()
// .catch()
// .finally()
// async
// await
// try
// catch
// finally
// callback hell
// OOP
// polymorphism
// inheritance
// encapsulation
// abstraction
// class
// object
// constructor
// method
// property
// this
// new
// functional programming
// higher order function
// closure
// currying
// recursion
// static
// super
// extends
// getter
// setter
// private
// public
// protected
// instanceof
// isPrototypeOf
// hasOwnProperty
// prototype
// **proto**
// naming convention in javascript:
// https://www.w3schools.com/js/js_conventions.asp
// https://www.robinwieruch.de/javascript-naming-conventions
// camelCase
// PascalCase
// snake_case
// kebab-case
// Meeting Monday
// Hour: 2:30 pm
// Invite:
// Ali
// Mina Essam
// Kamel Fahd
// Michael Adly
// Farid
// Paula
// Deras
// Petter
// Ahmed Hemaly
// Sammar
// ====
// After Seesion:
// Farid
// Paula