ul.insertAdjacentHTML(
"afterBegin",
DS.reduce(
(acc, cur) =>
acc + `<li data-cohorte=${cur.cohorte}>${cur.name}</li>`,
""
)
);
const showInfoCohorte = function ({ target }) {
student.innerText = target.dataset.cohorte;
};
ul.addEventListener("click", showInfoCohorte, false);
See the Pen students by SuperDupont (@SuperDupont) on CodePen.