Рассмотрим следующий код:
var animalSound = document.getElementById("animalSound");
Кнопка сброса:
var resetButton = document.querySelector("#reset");
Функция моей консоли сообщает, что значение равно null
:
resetButton.addEventListener("click", function(){
alert(" clicked button");
})
Животные, которых он выбирает:
var animals = ["elephant", "dog", "monkey", "zebra",
"parakeet", "cat", "pig", "Guerilla",
"skunk", "Leapord" ]
var x = animals[Math.floor(Math.random()*animals.length)];
animalSound.textContent = x;