-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript code for making card.js
31 lines (27 loc) · 1.11 KB
/
javascript code for making card.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
function createCard(title, cName, views, monthsOld, duration,) {
// Finish this function
let viewStr
if (views < 1000000) {
viewStr = views / 1000 + "k";
}
else if (views > 1000000) {
viewStr = views / 1000000 + "M";
}
else {
viewStr = views / 1000 + "k";
}
let html = ` <div class="container">
<div class="card">
<div class="image">
<img src="${thumbnail}"
alt="">
<div class="capsule">${duration}</div>
</div>
<div class="text">
<h1>${title}</h1>
<p>${cName} . ${viewNumber} views . ${monthsOld} months ago</p>
</div>
</div>`
document.querySelector(".container").innerHTML = document.querySelector(".container").innerHTML + html
}
createCard("Introduction to Backend | Sigma web dev video #2", "CodeWithHarry", "560000", 7, "31:22", "https://i.ytimg.com/vi/tVzUXW6siu0/hqdefault.jpg?sqp=-oaymwEcCPYBEIoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLACwWOixJVrKLFindK92kYMgTcQbw")