-
Notifications
You must be signed in to change notification settings - Fork 1
/
filter-objects-2.html
51 lines (33 loc) · 1.35 KB
/
filter-objects-2.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
44
45
46
47
48
49
50
51
<html>
<body>
<div class="wholeCard"> <!--color blue--> whole card
<div class="individualCard"> <!-- green -->
<div id="test1" class="flexboxContainerCard"> <!-- color red -->
</div>
</div>
</div>
</body>
<script>
var Usrdata = document.querySelector('.box');
var userDetail = [
{name:"sunil",age:"24",place:"delhi",avatar:"./image/abc.jpg",country:"India"},
{name:"sujan",age:"22",place:"assam,",avatar:"./image/abc.jpg",country:"India"},
{name:"abishek",age:"26",place:"kolkata",avatar:"./image/abc.jpg",country:"India"},
{name:"chiranjeev",age:"20",place:"bangalore",avatar:"./image/abc.jpg",country:"India"},
]
document.getElementById('test1').innerHTML = userDetail.map(user =>
`<div class="individualCard">
<div>Name: ${user.name}</div>
<div>Age: ${user.age}</div>
<div>Place: ${user.place}</div>
<div>Country: ${user.country}</div>
<div>Avatar: ${user.avatar}</div>
</div>`
).join('')
// ${} this syntax (used above) is using what's called string interpolation
// // An example of string interpolation
var name = 'Bob', time = 'today';
console.log(`Hello ${name}, how are you ${time}?`);
// Right click, click inspect and then click console to see the console.log above.
</script>
</html>