Repository navigation
Expand file tree
/
Copy pathhello.js
More file actions
191 lines (141 loc) · 3.63 KB
/
Copy pathhello.js
File metadata and controls
191 lines (141 loc) · 3.63 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
// document.write("Hello World!")
// let a = 1;
// for(let a=1;a<=10;a++){
// document.write("<br>");
// document.write(a);
// }
// let i = 1;
// switch(i){
// case 1:
// document.write(1);
// break;
// case 2:
// document.write(2);
// }
// let a = [1,2,3,4,5,6,7]
// for(let x in a){
// document.write(a[x])
// }
// let pTag = document.getElementById("vidya");
// pTag.addEventListener("mouseover",fun);
// function fun(event){
// console.log(event.target.innerHTML)
// // console.log(event.target.value)
// event.target.innerHTML = "This is vidyaVardhini."
// }
// class Shapes{
// constructor(height, width) {
// this.height = height;
// this.width = width;
// }
// }
// class Rectangle extends Shapes{
// constructor(height, width) {
// super(height,width);
// }
// perimeter() {
// return 2 *(this.height + this.width);
// }
// }
// let rec1 = new Rectangle(20,15);
// let p = document.getElementById("rect");
// p.innerHTML = rec1.perimeter();
// get area() {
// return (this.height * this.width);
// }
// height(){
// return (this.height);
// }
// class test {
// *generator(i) {
// while (true) {
// i = i + 10;
// yield i;
// }
// }
// }
// const t=new test();
// const gen=t.generator(10);
// console.log(gen.next().value);
// console.log(gen.next().value);
// console.log(gen.next().value);
// console.log(gen.next().value);
// console.log(((a)=> a + 100)(10))
// class A{
// alice = ()=> ()=>(a)=>{return a+100;}
// }
// let obj = new A();
// console.log(obj.alice()()(10));
// var arr = [5, 6, 13, 0, 1, 18, 23];
// var sum = arr.reduce((a, b) => a + b);
// var even = arr.filter((v) => v % 2 == 0);
// var double = arr.map((v) => v * 2);
// console.log(sum);
// console.log(even);
// console.log(double);
// console.log("good morning");
// setTimeout(()=>{console.log("done")},5000);
// console.log("waiting");
// let func1=()=>{func2()}
// let func2=()=>{console.log("hello");}
// func1();
// let addpos =(n1,n2)=>{
// return new Promise(function(resolve,reject){
// if(n1>0 && n2> 0)
// {
// resolve(n1+n2);
// }
// else
// {
// reject("number is not positive");
// }
// }
// )
// }
// addpos(10,10)
// .then((res)=>console.log(res,"success"))
// .catch((error1) => console.log(error1));
// function addpos(n1, n2) {
// let p = new Promise(function (resolve, reject) {
// if (n1 > 0 && n2 > 0) {
// resolve(n1 + n2);
// }
// else {
// reject("number is not positive");
// }
// }
// )
// return p;
// }
// addpos(10, 10)
// .then(success)
// .then((response)=>console.log(response))
// .catch(error1);
// function success(result) {
// return new Promise((resolve,reject)=>{
// if(result >= 0){
// resolve(result)
// }else{
// reject("promise not resolved");
// }
// })
// }
// function error1() {
// console.log(result);
// }
var promise = new Promise(function (resolve, reject) {
const x = "vcet"
const y = "vcet"
if (x == y) { resolve("equal"); }
else { reject("not equal") }
});
promise
.then( (response) => { console.log(response) })
.catch( (err) => { console.log(err) })
.finally(()=>console.log("It will run anyway"));
//FETCH API
// const fetch = require('node-fetch')
// fetch('https://jsonplaceholder.typicode.com/users')
// .then((response)=>response.json())
// .then((res)=>console.log(res))
// .catch()