I am a junior developer.. iam trying to typing a program that predicts the age of football players on the screen.. but the code does not work in a way I dont understand, what do you think the problem is? (iam typing 36 to the first image but it does not working)
var index = 0;
var images = document.getElementsByClassName("image");
var dots = document.getElementsByClassName("dot");
show_slide = (i) => {
index += i;
for (var j = 0; j < images.length; j++) {
images[j].style.display = "none";
}
for (var k = 0; k < dots.length; k++) {
dots[k].className = dots[k].className.replace(" active", "");
}
if (index > images.length - 1) {
index = 0;
}
if (index < 0) {
index = images.length - 1;
}
images[index].style.display = "block";
dots[index].className += " active";
}
window.addEventListener("load", function() {
show_slide(index);
});
function tahminEt() {
var dogruYas;
// İndekse göre doğru yaş değerini belirleyin
if (index === 1) {
dogruYas = 36; // Messi'nin yaşını buraya girin
} else if (index === 2) {
dogruYas = 32;
} else if (index === 3) {
dogruYas = 38;
} else if (index === 4) {
dogruYas = 31;
} else if (index === 5) {
dogruYas = 36;
} else {
document.getElementById('sonuc').textContent = "Maalesef yanlış tahmin ettiniz.";
return; // Doğru yaş değeri tanımlı değilse, fonksiyondan çık
}
var tahmin = parseInt(document.getElementById('tahmin').value);
if (isNaN(tahmin)) {
document.getElementById('sonuc').textContent = "Lütfen geçerli bir sayı girin.";
} else {
if (tahmin === dogruYas) {
document.getElementById('sonuc').textContent = "Tebrikler! Doğru tahmin ettiniz.";
// Doğru tahmin yapıldığında bir sonraki fotoğrafa geç
show_slide(1);
} else {
document.getElementById('sonuc').textContent = "Maalesef yanlış tahmin ettiniz.";
}
}
}
i do wanna what is the problem and how can i fix it