-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (35 loc) · 1.49 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
// fetch( 'https://randomuser.me/api/')
// .then(function(perponse){
// return perponse.json();
// })
// .then(function(data){
// console.log(data)
// })
// old way
// in down modern way for fetch Api
async function giveMe(){
const response = await fetch(`https://randomuser.me//api/1.3`);
const myData = await response.json();
const sc = myData.results[0].picture.large;
const {title , first , last} = myData.results[0].name;
const{country , city }= myData.results[0].location
const age = myData.results[0].dob.age ;
const{email , phone , cell }= myData.results[0]
document.querySelector("img").src = sc;
document.getElementById("name").innerHTML = ` ${first} ${last}`;
document.getElementById("age").innerHTML = `Age: ${age} `;
document.getElementById("counter").innerHTML = `Counter : ${country} / ${city} `;
document.getElementById("cell").innerHTML = ` ${phone} / ${email} `;
document.getElementById("code").innerHTML = ` ID Code : ${cell} `;
let resulte = document.getElementById("resulte")
age > 60
?resulte.innerHTML = `Resulte : ${title} ${first} Old over (60) `
:age > 50
?resulte.innerHTML = `Resulte : ${title} ${first} bigger than (50) `
:age > 40
?resulte.innerHTML = `Resulte : ${title} ${first} bigger than (40) `
:age > 30
?resulte.innerHTML = `Resulte : ${title} ${first} bigger than (30) `
:resulte.innerHTML = `Resulte : ${title} ${first} a young under (30) `
}
giveMe()