I am doing a course for Js and an almost existential doubt arose. I attach the code below
function leerDatosCurso(curso) {
const infoCurso = {
imagen: curso.querySelector('img').src,
titulo: curso.querySelector('h4').textContent,
precio: curso.querySelector('.precio span').textContent,
id: curso.querySelector('a').getAttribute('data-id')
}
añadirCarrito(infoCurso);
}
function añadirCarrito(curso) {
const row = document.createElement('tr');
row.innerHTML = '
<td><img src="${curso.imagen}"></td>
<td>${curso.titulo}</td>
<td>${curso.precio}</td>
<td>
<a href="#" class="boton-borrar" data-id="${curso.id}">X</a>
</td>
';
//agrego este template a lista cursos
listaCursos.appendChild(row);
}
I can not elucidate the following .. for the function addCarrito I pass it as an argument course ... all right up there, but because in the function of readingCatData (within this) we call the addCarrito function ( infoCurso ). if afterwards for the addCarrito function I use another parameter.
ANY HELP HELPS TO CONTINUE LEARNING FRIENDS.