it is my first question in the community
Hello everyone! Now i am practicing JS classes. In the code below i want to make cards of products with with courses of programming languages, i have created array with data which must be added to html body ,see Render class
const div = document.getElementById('app')
class Arguments {
constructor(title, img, depiction, price) {
this.title = title
this.img = img
this.depiction = depiction
this.price = price
}
}
class Render {
cards = [
new Arguments('Python BootCamp', 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR7qKCjl9JJDnFDvf-U4Sv_YR5iXWGZbu-QRXNDZ5peS_Nusg8Sh8fb5lk5IbH9_MqSIIE&usqp=CAU', 'In this Complete Python course, you will learn everything you need to know about Python programming. You will start from very basics towards to the advance', 0.00,),
new Arguments('JavaScript Crash Course', 'https://i.ytimg.com/vi/nN_qBdgmQpw/maxresdefault.jpg', 'A crach course by professional JS-DEVELOPER who"s wage $10000+', 300.00),new Arguments('JAVA COURSE', 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSvZ2DvlygW--TMKhrSO4SfA-6Op1QmVUXmh2dqtGxbHxPyvYH9elzpu-xGy2FOPac9VcE&usqp=CAU', 'A profi"s java totrial ', 70.00,),
]
render() {
const ul = document.createElement('ul')
const li = document.createElement('li')
for (const elm of this.cards) {
li.classList.add = 'card'
li.innerHTML = `<h1>${elm.title}</h1><img src='${elm.img}'><p>${elm.depiction}</p><h3>${elm.price}</h3>`
ul.append(li)
}
div.append(ul)
}
}
const Project = new ProductsList_Render
Project.render()
I encounter with a problem ! It adds only last element of the array but we can see the length of cards is 3. I thought that for-of loop returns only one result not more but...
let array=[1,2]
for (const iterator of array) {
console.log(iterator);
}
How to fix it.