0
What’s wrong with that code? In the first item of the catalog has 2 images, and in the second item has 1 image (JSON). But on the page when executed it shows the first item with all 3 photos and the second item is correct (only with the last).
What could it be? (Obs. I’m new to programming, so take it easy kkkk) Thanks
catalogo = [
{
'nome': 'Polo Masculina Detalhe',
'tamanhos': 'Disponivel nos tamanhos P, M, G, GG',
'avista': '39,90',
'aprazo': '42,90',
'imgs': [
{
'cod': 'COD: 1010',
'ft': '<img src="imgs/36.webp">'
},
{
'cod': 'COD: 1011',
'ft': '<img src="imgs/37.webp">'
}
]
},
{
'nome': 'Polo Masculina Outr',
'tamanhos': 'Disponivel nos tamanhos P, M, G, GG',
'avista': '39,90',
'aprazo': '42,90',
'imgs': [
{
'cod': '1113',
'ft': '<img src="imgs/5.webp">'
}
]
}
]
for (var p = 0; p < catalogo.length; p++) {
var sessao = `
<section class="sec">
<div class="detalhes">
<h2>${catalogo[p].nome}</h2>
<p class="descricao">${catalogo[p].tamanhos}</p>
<span class="precoVista">${catalogo[p].avista}</span>
<span class="precoPrazo">${catalogo[p].aprazo}</span>
</div>
</section>
`
$('.corpo').append(sessao);
for (var i = 0; i < catalogo[p].imgs.length; i++) {
var imagem = `
<div class="item">
${catalogo[p].imgs[i].ft}
<span class="cod">${catalogo[p].imgs[i].cod}</span>
</div>
`
$('.sec').append(imagem)
}
}
puts html tbm and tries to assemble this example working to make it clearer
– Ricardo Pontual