-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
43 lines (37 loc) · 1.31 KB
/
index2.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>User Data From Json Placeholder</h1>
<ul id="user-list">
</ul>
<ul id="email-list">
</ul>
<script>
fetch('https://jsonplaceholder.typicode.com/users')
.then(response => response.json())
.then(json => userDataForm(json))
const userDataForm = user =>{
const userName = user.map(name => name.username);
const userEmail = user.map(email => email.email);
const ul = document.querySelector("#user-list");
const ul2 = document.querySelector("#email-list");
for(let i = 0; i < userName.length; i++){
const name = userName[i];
const li = document.createElement("li");
li.innerText = name;
ul.appendChild(li);
}
const userInformation = userEmail.map(function(email){
const li = document.createElement("li");
li.innerText = email;
ul2.appendChild(li);
})
}
</script>
</body>
</html>