-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (24 loc) · 925 Bytes
/
index.js
File metadata and controls
31 lines (24 loc) · 925 Bytes
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
const image = document.getElementById("img")
const phoneelem = document.getElementById("phone")
const nameelem = document.getElementById("name")
const email = document.getElementById("email")
const locat = document.getElementById("location")
const getUser = function(){
fetch("https://randomuser.me/api/")
.then(res => res.json())
.then(user => {
user = user.results[0]
let name, mail, location, phone, nat, picture, birth
name = user.name.first[0].toUpperCase() + user.name.first.slice(1, user.name.first.length) + " " + user.name.last[0].toUpperCase() + user.name.last.slice(1, user.name.last.length)
mail= user.email
phone = user.phone
picture = user.picture.large
location = capitalize(user.location.city) + " - " + capitMore(user.location.street)
locat.innerHTML = location
image.src = picture
nameelem.innerHTML = name
phoneelem.innerHTML = phone
email.innerHTML = mail
})
}
getUser()