The code should display a text input area and an Enter button. Then the computer should assign a random number. The user should be able to guess the number with the help of tip like "too big or too small" and the user loses if the tries go above 9. When i try to guess the number by entering my number and pressing enter it does give this error-> "Uncaught TypeError: guess is not a function at HTMLButtonElement.onclick (Website-VSC.html:88)" i realy have no idea how to fix this.
randomnum = Math.floor(Math.random() * 1001);
tries = 10;
function guess() {
tries--;
if (document.getElementById("input").value == randomnum) {
document.getElementById("input").select();
document.getElementById("result").innerHTML = "Gut";
}
if (document.getElementById("input").value < randomnum) {
document.getElementById("input").select();
document.getElementById("help").innerHTML = "Zu Klein";
}
if (document.getElementById("input").value > randomnum) {
document.getElementById("input").select();
document.getElementById("help").innerHTML = "Zu Groß";
}
if (tries = 0) {
document.getElementById("input").select();
document.getElementById("result").innerHTML = "Du hast keine versucher mehr"
}
}
document.getElementById("guess").addEventListener("click", guess);
<section id="spiel">
<h2>Ein kleines Zahl Spiel</h2>
<p> Der Rechner wird ein zahl zwischen 1 und 1000 wahlen. Als spieler muss du raten welche zahl es ist. Schreib deine antworten in unten gegebene feld.</p>
<p id="help"></p>
<input type="text" id="input" maxlength="4">
<button type="button" onclick="guess()" id="guess">Enter</button>
<p id="result"></p>
</section>