-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculatorWithDiffMethods.html
More file actions
239 lines (198 loc) · 5.25 KB
/
calculatorWithDiffMethods.html
File metadata and controls
239 lines (198 loc) · 5.25 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html>
<head>
<title>calculator-prompt</title>
</head>
<body>
<!-- <div class="fix" style="position: relative; background-color: red;width: 50%; height: 20px;">vfdzcd
</div>
<div class="rel" style="position: absolute; background-color: blue;width: 50%;height: 20px;">cdsuikjc
</div>
<div class="abs" style="position: fixed; background-color: pink;width: 50%; height: 20px; ">qwerty
</div>
<div class="abs" style="position: static; background-color: black;width: 50%; height: 20px; ">ASQWRS
</div> -->
<div id="twitter_status"></div>
<script>
// let calculator ={
// sum(){
// return this.a + this.b;
// },
// mul(){
// return this.a * this.b;
// },
// read(){
// this.a =+ prompt("Enter the value of a?","0");
// this.b =+ prompt("Enter the value of b?","0");
// }
// };
// calculator.read();
// console.log(calculator.sum());
// console.log(calculator.mul());
// setTimeout(console.log(1),1000);
// setTimeout(console.log(2),);
// setTimeout(console.log(3),0);
// window.onload = function() {
// for(var i = 1; i < 21; i++) {
// var button = document.createElement("button");
// var text = document.createTextNode(i);
// button.appendChild(text);
// button.addEventListener("click", function() {
// alert(this.firstChild.nodeValue);
// });
// document.body.appendChild(button);
// }
// }
// function electionWinner(votes) {
// const voting = {};
// for(let v of votes){
// voting[v] = (voting[v] || 0) + 1;
// }
// let winners = [];
// let maxVotes = 0;
// for(let name in voting){
// if(voting[name] > maxVotes){
// maxVotes = voting[name];
// winners = [name];
// }
// else if (voting[name] === maxVotes){l
// winners.push(name);
// }
// }
// if(winners.length === 1){
// return winners[0];
// }
// winners.sort();
// return winners[winners.length - 1];
// }
// let winwin = [ "zella", "mary", "joe", "joe", "zella"];
// let abc = electionWinner(winwin);
// console.log(abc);
//let res = {};
// var res = [];
// var res;
// console.log(check(res));
// function check(res){
// if(res = {}){
// for(let key in res){
// console.log(1);
// return false;
// }
// console.log(2);
// return true;
// } else if(Array.isArray(res = []) && res.length <= 0){
// console.log("abc");
// } else {
// console.log("error")
// }
// }
// var obj = {}
// var obj = [];
// console.log(isEmpty(obj))
// function isEmpty(obj) {
// for(var key in obj) {
// if(obj.hasOwnProperty(key))
// return false;
// }
// return true;
// }
// if (Array.isArray(obj) && obj.length > 0) {
// console.log("1");
// }
// else {
// console.log("2");
// }
// function counter (){
// var n = 0;
// return {
// count: function(){ return n++; },
// reset: function(){n=0;}
// };
// }
// var c= counter(), d= counter();
// console.log(c.count());
// console.log(d.count());
// console.log(c.reset());
// console.log(c.count());
// console.log(d.count());
// var a = 5;
// function one(){
// a=6;
// }
// function two(){
// alert(a);
// }
// two();
// function changeType(){
// var type=['mac','1'];
// var element = document.getElementById('testField').value;
// // console.log(element)
// var testObject = [];
// for (var i=1; i<=element; i++){
// // testObject.push({
// // [type[0]+'' + i] : i
// // });
// // console.log("111",testObject);
// key = type[1]+'' + i
// console.log(key);
// }
// }
function addNo() {
var allno = [1,2,3,4,5];
var targetNo = 5;
for(var i =0; i <= allno.length-1; i++){
for (var j = i + 1; j < allno.length; j++){
if (allno[i] + allno[j] == targetNo){
console.log("success", allno[i] , allno[j]);
}
}
}
}
addNo();
// Clousure//
// var a = 100;
// function first() {
// var b = 200;
// function second() {
// console.log("Value-->", b);
// console.log("Value-->", a);
// }
// second();
// }
// first();
////////////
// function missingNum(nums){
// const numberArray = nums.sort((num1, num2)=>{
// return num1 - num2;
// });
// for (let i=0; i < numberArray.length; i++){
// if(i !== numberArray[i]){
// return i;
// }
// }
// }
// console.log(missingNum([0,3,5,8,2,6,1,9,7]))
// var ula=document.createElement('ul');
// for(j=0; j<5;j++){
// var ul=document.createElement('ul');
// ul.innerHTML="<li>UL TEXT</li>";
// ula.appendChild(ul);
// for(i=0;i<5;i++)
// {
// var li=document.createElement('li');
// li.innerHTML="LI TEXT";
// ul.appendChild(li);
// for(k=0; k<5;k++){
// var li=document.createElement('li');
// li.innerHTML="SUB LI TEXT";
// ul.appendChild(li);
// }
// }
// }
// document.getElementById('twitter_status').appendChild(ula);
// console.log(findMissing([1,2,3,4,5,6,8,9,10,11,12,13,14]))
</script>
<!-- <input type="number" name="typetest" id="testField">
<input type="submit" name="submitText" onclick="changeType()"> -->
</body>
</html>