if (index === 0) {
const image = document.createElement('img');
image.alt = 'image';
image.src = 'https://media.s-bom.com';
image.width = '100';
li.appendChild(image);
}
if (index === 1) {
const image = document.createElement('img');
image.alt = 'image';
image.src =
'https://images-na.ssl-images-amazon.com';
image.width = '100';
li.appendChild(image);
}
if (index === 2) {
const image = document.createElement('img');
image.alt = 'image';
image.src =
'https://upload.wikimedia.orgmmer.jpg/220px-The_pragmatic_programmer.jpg';
image.width = '100';
li.appendChild(image);
}
Hey, I have this code above in if condition and I want it to be more clear and not repeated, so anyone have idea how to be more clean.
Aucun commentaire:
Enregistrer un commentaire