-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
29 lines (28 loc) · 949 Bytes
/
main.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
(async function(){
const response=await fetch ('https://jsonplaceholder.typicode.com/todos')
const data=await response.json()
for(let user of data){
/* console.log(users) */
/* console.log(users.name) */
const newTr=document.createElement("TR")
tableId.appendChild(newTr)
const newId=document.createElement('TD')
newId.textContent=user.userId
newTr.appendChild(newId)
//userid
const newUserId=document.createElement('TD')
newTr.appendChild(newUserId)
newUserId.textContent=user.id
//title
const newTitle=document.createElement('TD')
newTr.appendChild(newTitle)
newTitle.textContent=user.title
//complated
const newCompleted=document.createElement('TD')
newTr.appendChild(newCompleted)
newCompleted.textContent=user.completed
if (user.completed===true){
newCompleted.style.backgroundColor='green'
}else {newCompleted.style.backgroundColor='red'}
}
})()