-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountry.js
More file actions
70 lines (60 loc) · 1.63 KB
/
country.js
File metadata and controls
70 lines (60 loc) · 1.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
let url = "http://universities.hipolabs.com/search?name=india";
let btn = document.querySelector("button");
// btn.addEventListener("click" ,async ()=>{
// let country=document.querySelector("input").value;
// console.log(country);
// let colArr=await getColleges(country);
// console.log(colArr);
// show(colArr);
// });
// function show(colArr){
// let list=document.querySelector("#list");
// list.innerTextL=""
// for(col of colArr){
// console.log(col.name);
// let li=document.createElement("li");
// li.innerText=col.name;
// list.appenChild(li);
// }
// }
// async function getColleges(){
// try {
// let res= await axios.get(url+country);
// return res.data;
// }catch(e){
// console.log("error -",e);
// return [];
// }
// }
btn.addEventListener("click", async () => {
let state = document.querySelector("input").value;
console.log(state);
let colArr = await getColleges(state);
console.log(colArr);
show(colArr);
})
function show(colArr) {
let list = document.querySelector("#list");
list.innerText = "";
for (col of colArr) {
console.log(col.name);
let li = dcoument.createElement("#list");
li.innerText = col.name;
list.appenChild(li);
}
}
async function getColleges() {
try {
let result = await axios.get(url + state);
return result.dasta;
} catch (err) {
console.log("error -", err);
return [];
}
}
for(let i=0; i<=5; i++){
console.log(i);
}
for(let i=5; i>=0; i--){
console.log(i);
}